python异常处理

  1. sys.exc_info() 获取异常
import sys

try:
     raise ValueError('this is a exp')
except Exception as ex:
    ex_type, ex_val, ex_stack = sys.exc_info()
    print(ex_type)
    print(ex_val)


posted @ 2021-04-14 10:14  该显示昵称已被使用了  阅读(38)  评论(0编辑  收藏  举报