問題:
I am not sure why we need finally
in try...except...finally
statements.我不確定爲什麼我們需要finally
in try...except...finally
語句。 In my opinion, this code block在我看來,這個代碼塊
try:
run_code1()
except TypeError:
run_code2()
other_code()
is the same with this one using finally
:與使用finally
這個相同:
try:
run_code1()
except TypeError:
run_code2()
finally:
other_code()
Am I missing something?我錯過了什麼嗎?
解決方案:
參考一: https://stackoom.com/question/mTCW參考二: Why do we need the “finally” clause in Python?