Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python get exception message

try:
    with open(filepath,'rb') as f:
        con.storbinary('STOR '+ filepath, f)
    logger.info('File successfully uploaded to '+ FTPADDR)
except Exception as e: # work on python 3.x
    logger.error('Failed to upload to ftp: '+ str(e))
Comment

python get exception message

try:
  # do something
  pass
except:
  # this will print the message "An exception occurred and the traceback" 
  # you can't have to explicitly give the message
  logger.exception("An exception occurred")
Comment

how to print python exception message

print(repr(e)) # Returns both the message and type of exception
Comment

python get message exception

str(your_exception)
Comment

PREVIOUS NEXT
Code Example
Python :: cmd python -m 
Python :: How to convert text into audio file in python? 
Python :: how to create a file in a specific location in python 
Python :: tkinter button background color mac 
Python :: f string decimal places 
Python :: install django windows 
Python :: pandas merge dataframes from a list 
Python :: rename files in folder python 
Python :: start new app in django 
Python :: python how to get alphabet 
Python :: cross validation python 
Python :: migrate using other database django 
Python :: how to code in python 
Python :: palindrome Rearranging python one line 
Python :: Import "dj_database_url" could not be resolved Pylance 
Python :: prime number generator python 
Python :: pyqt5 latex 
Python :: convert string representation of a list to list 
Python :: how to get user ip in python 
Python :: remove turtle 
Python :: loop through 2 dataframes at once 
Python :: mouse module python 
Python :: count unique values in pandas column 
Python :: python random choice in list 
Python :: while loop countdown python 
Python :: export csv from dataframe python 
Python :: django staff required 
Python :: time delta python 
Python :: add time delta pytohn 
Python :: django create model from dictionary 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =