[問題] exception
使用 Tkinter 當 UI 時,該如何讓未處理的 exception 能停止整個程式呢?
以底下這個程式為例子來說:
from Tkinter import *
def raiseException():
raise Exception('unhandled exception')
root = Tk()
Button(root, text = 'Button', command = raiseException).pack()
root.mainloop()
使用者按下按鈕後,會產生一個沒人處理的 exception
在 C++,這會導致整個程式崩潰掉
可是在使用 Tkinter 的 python 程式裡,只會在 console 冒出錯誤訊息
程式還是活的好好的
請問要怎樣修改才能讓程式像 C++ 一樣崩潰掉?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.170.57.216
→
10/02 00:49, , 1F
10/02 00:49, 1F
Python 近期熱門文章
PTT數位生活區 即時熱門文章