python try打印完整错误信息

python try打印完整错误信息

import sys

try:
  int("qwer")
except ValueError as e:
  print(sys.exc_info())

  输出:
  (<class 'ValueError'>, ValueError("invalid literal for int() with base 10: 's'"), <traceback object at 0x7fa8c41a5bc0>)

你可能感兴趣的:(Python学习笔记,python)