Answers for "python error get line"

1

python get line of exception

except Exception as e:
Posted by: Guest on December-26-2020
0

python error get line

import sys
try:
    print(5/0)
except Exception as e:
    print('Error on line {}'.format(sys.exc_info()[-1].tb_lineno), type(e).__name__, e)

print('And the rest of program continues')
Posted by: Guest on September-09-2021

Code answers related to "python error get line"

Python Answers by Framework

Browse Popular Code Answers by Language