嗨,大家好,我只是python的初學者。我研究了異常處理,它對我來說非常困難。我的代碼是Python的異常處理
def exceptionhandling(z,y):
hd = z
hs = y
try:
sd = hd/hs
except ZeroDivisionError as err
print "this cannot be possible".err
當我調用的函數exceptionhandling(1,0)
我沒有得到預期的輸出「這可能是不可能的」。
請幫助我理解這一個..如果這是一個低標準的新人如此如此抱歉。
你得到的輸出是什麼?我期望一個SyntaxError或IndentationError。 – Matthias
indentationerror – user3356408
查看固定代碼並在except行的末尾添加「:」。 – Matthias