wxpython用来创建窗口应用程序,但有时候我们希望能在控制台输出一些异常或者错误提示,这段代码能够帮助你实现
import sys STDERR = sys.stderr # Keep stderr because wxPyhon will redirect it. import wx [...your wxPython program goes here...] if __name__ == "__main__": import traceback,sys try: app = MyWxApplication() # Start you wxPython application here. app.MainLoop() except: traceback.print_exc(file=STDERR)