try:
print(a)
except Exception as e:
print(e)
print(e.__traceback__.tb_frame.f_globals["__file__"]) # 發生異常所在的文件
print(e.__traceback__.tb_lineno) # 發生異常所在的行數
參考
https://blog.csdn.net/little_stick_i/article/details/120973526
This article was first publish
Day10 A baseball and a bat wit