【发布时间】:2017-12-21 05:49:49
【问题描述】:
如何打印python异常?
例子:
try:
action()
except:
print "Unexpected error:", sys.exc_info()[0]
打印:
Unexpected error: <type 'exceptions.TypeError'>
它对我来说没有太多信息。
【问题讨论】:
-
您还想知道什么?
-
为什么会提出例外?还是在哪里?
-
注意简单的方法:
except Exception as e,print e -
那么他们呢?你做过研究吗? stackoverflow.com/questions/22232201/…, stackoverflow.com/questions/4690600/…, ...