how to catch all uncaught exceptions and go on?

后端 未结 2 1768
暗喜
暗喜 2021-01-20 10:15

EDIT: after reading the comments and the answers I realize that what I want to do does not make much sense. What I had in mind was that I h

2条回答
  •  情歌与酒
    2021-01-20 10:58

    Are you after:

    import traceback
    import sys
    
    try:
        raise ValueError("something bad happened, but we got that covered")
    except Exception:
        print("--------------")
        print(traceback.format_exception(sys.exc_info()))
        print("--------------")
    print("still there")
    

提交回复
热议问题