Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

catch error data with except python

import sys
try:
	S = 1/0 #Create Error
except: # catch *all* exceptions
    e = sys.exc_info()
    print(e) # (Exception Type, Exception Value, TraceBack)

############
#    OR    #
############
try:
	S = 1/0
except ZeroDivisionError as e:
    print(e) # ZeroDivisionError('division by zero')
Comment

PREVIOUS NEXT
Code Example
Python :: how to make addition in python 
Python :: import file from parent directory python 
Python :: __new__ python 
Python :: iterate backwards through a list python 
Python :: python dictionary get 
Python :: how to logout in django 
Python :: how to use cos in python 
Python :: list from comma separated string python 
Python :: python password with special characters 
Python :: python how to delete a directory with files in it 
Python :: get an item out of a list python 
Python :: python compare timestamps 
Python :: python array append 
Python :: dataframe select data type 
Python :: breadth first search python 
Python :: execute terminal command from python 
Python :: how to run django in jupyter 
Python :: google translator api pyhton 
Python :: pandas remove leading trailing spaces in dataframe 
Python :: code for python shell 3.8.5 games 
Python :: python read file into variable 
Python :: get_dummies 
Python :: pyplot savefig 
Python :: one hot encoding 
Python :: rename in python 
Python :: sort first element reverse sort second python 
Python :: pyplot python 
Python :: how to fix valueerror in python 
Python :: open file in python directory 
Python :: primary key auto increment python django 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =