我得到這個錯誤:TypeError:我的代碼不支持的操作數類型?
Traceback (most recent call last):
File "exceptionhandling.py", line 2, in <module>
x = 5 + "ham" TypeError: unsupported operand type(s) for +: 'int' and 'str'
我的代碼:
try:
x = 5 + "ham"
except ZeroDivisionError:
print("won't see this")
finally:
print("The final word")
我學習異常處理。我知道5 + "ham"
會出現錯誤,我不應該看到"won't see this"
,但爲什麼會出現此錯誤?
你爲什麼試圖捕捉一個'ZeroDivisionError'? – 2014-10-05 20:22:09