繁体   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