2024-06-16 12:44:59 发布
网友
对于Python来说,这是一个新的功能,但是它为什么不能产生一个整数>;<;我在值前面添加了int,希望通过将它们具体设置为int,我不会得到40.0%的回报,我只想说40%
score = 4 opLimit = 10 total = int(100) * int(score)/int(oqLimit) print(total,"%")
如果你在Python3上,你应该使用字符串格式。在
score = 4 opLimit = 10 total = 100 * score/oqLimit print("{:.0f}%".format(total)) # {...} defines a substitution field # :... defines the formatting options # .0f indicates to represent floats with 0 digits after the decimal
如果你在Python3上,你应该使用字符串格式。在
相关问题 更多 >
编程相关推荐