Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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')
Comment

PREVIOUS NEXT
Code Example
Python :: numpy compare arrays 
Python :: numpy fill na with 0 
Python :: django add media 
Python :: tick labels vertical matplotlib 
Python :: python remove cached package 
Python :: inspectdb django 
Python :: install easygui 
Python :: Python - How to check if string is a HEX Color Code 
Python :: how to multiply in django template 
Python :: correlation between lists python 
Python :: convert mp3 to wav python 
Python :: python 2 decimal places 
Python :: string to datetime 
Python :: set cuda visible devices python 
Python :: conda python 3.8 
Python :: install models python 
Python :: pandas concat and reset index 
Python :: python ftp upload file 
Python :: convert epoch to date time in python 
Python :: distance euc of two arrays python 
Python :: plotly set axes limits 
Python :: python runtime 
Python :: python split range equally 
Python :: pyautogui keyboard write 
Python :: python divide string in half 
Python :: csv to numpy array 
Python :: save list python 
Python :: copy text python 
Python :: python create nested directory 
Python :: install library from python code 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =