簡體   English   中英

如何解決python中的“無法將序列乘以'float'類型的非整數”的問題

[英]How do I solve the issue “can't multiply sequence by non-int of type 'float'” in python

string = (input("Input a string of random chars! "))
multi = int(len(string))
multi1 = float(multi)
print(multi)
print(("-") * round((multi * 10),1))
print("|", ("_") * round((multi1/2),1), "|")

您需要int來重復字符串

print("|", ("_") * int(round((multi1/2),1)), "|")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM