不知道爲什麼,但這個簡單的Python代碼是給我的錯誤:簡單的Python打印命令給予不支持的類型錯誤
'''
Created on Aug 2, 2017
@author: Justin
'''
x = int(input("Give me a number, now....."))
if x % 2 != 0:
print(x + " is an odd number!")
else:
print(x + " is an even number!")
錯誤是說:
Traceback (most recent call last):
File "C:\Users\Justin\Desktop\Developer\Eclipse Java Projects\PyDev Tutorial\src\Main\MainPy.py", line 9, in <module>
print(x + " is an odd number!")
TypeError: unsupported operand type(s) for +: 'int' and 'str'
請幫幫忙!
謝謝!
錯誤消息說,這一切:你想加在一起一個int和一個字符串。這是行不通的。將int轉換爲字符串,然後將它們加在一起 –