雖然我輸入了一個數值,但它仍然給我一個錯誤。我不知道這是爲什麼發生..幫助某人?def python錯誤重複
def is_string(s):
rate = input(s)
try:
str.isalpha(rate)
print('There was an error. Please try again. Make sure you use numerical values and alpabetical. ')
return is_string(s) #ask for input again
except:
return rate
ExRate = is_string('Please enter the exchange rate in the order of, 1 '+Currency1+' = '+Currency2)
def is_string2(msg):
amount = input(msg)
try:
str.isalpha(amount)
print('There was an error. Please try again. Make sure you use numerical values. ')
return is_string2(msg) #ask for input again
except:
return amount
Amount = is_string2('Please enter the amount you would like to convert:')
你在這裏做什麼? – Eric 2013-03-23 22:53:18
閱讀['isalpha()'](http://docs.python.org/2/library/stdtypes.html#str.isalpha)的文檔,您可能會發現錯誤。 – millimoose 2013-03-23 22:54:05
你的'try'子句的哪一部分是你期望拋出一個錯誤?打印「出現錯誤」不足以從「try」語句中斷開。 – Eric 2013-03-23 22:54:28