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) 提问前请先上网搜索。 python-when-i-catch-an-exception-how-do-i-get-the-type-file-and-line-number
提问前请先上网搜索。
python-when-i-catch-an-exception-how-do-i-get-the-type-file-and-line-number