2019-02-15
閱讀量:
841
python try...except中如何輸入e的行號(hào)
python try...except中如何輸入e的行號(hào)?
try:
print(aaa)
except Exc eption as e:
print (e)
答:舉例來(lái)說(shuō)
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)






評(píng)論(0)


暫無(wú)數(shù)據(jù)
CDA考試動(dòng)態(tài)
CDA報(bào)考指南
推薦帖子
0條評(píng)論
0條評(píng)論
0條評(píng)論
0條評(píng)論