finally

無論如何都會執行。

try:
    f = open("file.txt")
finally:
    f.close()  # 一定會執行
💻 程式碼編輯器
📤 執行結果
等待執行...
← 上一課 下一課 →