try-except

捕獲並處理例外。

try:
    result = 10 / 0
except ZeroDivisionError:
    print("不能除以零!")

練習

處理使用者輸入可能的錯誤

💻 程式碼編輯器
📤 執行結果
等待執行...
下一課 →