我需要有计算后的百分比符号,我怎样才能改变这种代码,以便将错误:添加字符串到整数
TypeError: unsupported operand type(s) for +: 'int' and 'str'
不显示。要删除小数点,计算为'int'。
global score
score = 2
def test(score):
percentage = int(((score)/5)*100) + ("%")
print (percentage)
test(score)
投下你的号码为字符串。 –
你*仍*需要将数字*返回*转换为str。 – Mangohero1