2019-02-15
阅读量:
808
python try...except中如何输入e的行号
python 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条评论