python – traceback.format_exc / print_exc在期待回溯时返回
发布时间:2020-12-16 22:12:25 所属栏目:Python 来源:网络整理
导读:我无法弄清楚为什么traceback.format_exc()在以下示例中返回“None”: #!/usr/bin/env pythonimport sysimport tracebackdef my_excepthook(type,value,tb): print type.__name__ print value # the problem: why does this return "None"? print traceback
我无法弄清楚为什么traceback.format_exc()在以下示例中返回“None”:
使用Python 2.7.1,我得到以下输出:
而不是第3行的“无”,我希望得到当我注释掉sys.excepthook行时会发生什么:
最佳答案
尝试在my_excepthook中更改为:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |