python 异常和弹出框
import tkinter.messagebox try: fileContent = open("abnormal.txt") fileContent.close() print("over") #把异常消息赋予一个"ex"变量 except Exception as ex: print(ex) tkinter.messagebox.showinfo("Alert",ex) tkinter.messagebox.askyesnocancel("askyesnocancel","Error Message:\n%s"%ex) tkinter.messagebox.showinfo("showinfo","Error Message:\n%s"%ex) tkinter.messagebox.showwarning("showwarning","Error Message:\n%s"%ex) tkinter.messagebox.showerror("showerror","Error Message:\n%s"%ex) tkinter.messagebox.askquestion("askquestion","Error Message:\n%s"%ex) tkinter.messagebox.askokcancel("askokcancel","Error Message:\n%s"%ex) tkinter.messagebox.askretrycancel("askretrycancel","Error Message:\n%s"%ex)