Handle Arbitrary Exception, Print Default Exception Message

前端 未结 5 625
我寻月下人不归
我寻月下人不归 2021-01-01 16:00

I have a program, a part of which executes a loop. During the execution of this loop, there are exceptions. Obviously, I would like my program to run without errors, but for

5条回答
  •  感情败类
    2021-01-01 16:37

    I find this to be much more useful for debugging:

    from traceback import print_exc
    try:
        raise Exception("doh!")
    except:
        print_exc()
    

提交回复
热议问题