我需要有計算後的百分比符號,我怎樣才能改變這種代碼,以便將錯誤:添加字符串到整數
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