Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我应该更喜欢sys.exc_info()和sys.last_value朋友(sys.last_type,sys.last_traceback)吗?
sys.exc_info()
sys.last_value
sys.last_type
sys.last_traceback
查看sys.last_value和朋友的文档:
它们的预期用途是允许交互式用户导入调试器模块并进行事后调试,而无需重新执行导致错误的命令。
因此,如果您在解释器中进行调试,我建议您使用sys.last_value,但在脚本中我建议您使用sys.exc_info().