Skip to content

Latest commit

 

History

History
7 lines (4 loc) · 770 Bytes

07-error-handling.md

File metadata and controls

7 lines (4 loc) · 770 Bytes

(原教材及範例程式碼網址)

例外處理 Error handling

在 Python 中我們使用 try/except/finally 來處理例外

當你使用 except 去捕捉各種例外狀況時,先從你認為最精確與最常見的例外開始 (例如 FileNotFoundError),最後再到最一般性的例外 (也就是只有 except:, 不指定例外的種類)。Python 內建了幾十種例外種類,你可以在此處查詢各種例外的階層關係