python: How do I know what type of exception occurred?

后端 未结 15 2057
情书的邮戳
情书的邮戳 2020-11-29 14:56

I have a function called by the main program:

try:
    someFunction()
except:
    print \"exception happened!\"

but in the middle of the ex

15条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 15:12

    Just refrain from catching the exception and the traceback that Python prints will tell you what exception occurred.

提交回复
热议问题