exception get line number python
import traceback
try:
print(4/0)
except ZeroDivisionError:
print(traceback.format_exc())
exception get line number python
import traceback
try:
print(4/0)
except ZeroDivisionError:
print(traceback.format_exc())
python get line number of error
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)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us