2019-04-11
阅读量:
796
try...except中如何输入e的行号
问题描述:
try...except中如何输入e的行号?
try:
print(aaa)
except Exc eption as e:
print (e)
解决方法:
import sys, os
try:
raise NotImplementedError("No error")
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print(exc_type, fname, exc_tb.tb_lineno)






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论