📜  异常获取行号python代码示例

📅  最后修改于: 2022-03-11 14:47:14.258000             🧑  作者: Mango

代码示例2
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)