我是編程新手。如果我輸入一個字符串,如何在Python中使用if else
語句來獲取錯誤消息。我試圖在Python中輸入字符串,你可以教我
x = int(input("Enter the no."))
if (x>5):
print (x ,'Is greater than 5')
elif (x==str):enter code here
print('Incorrect input')
elif (x==5):
print (x ,'Is equal to 5')
elif (x<5):
print (x ,'Is less than 5')
else:
print (x ,'none of the above!')
[在Python 3輸入字符串]輸入任何非數字到的輸入 – Sayse
可能的複製(http://stackoverflow.com/questions/16625669/input-string-in-python-3) –