Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python write error to file

logf = open("download.log", "w")
for download in download_list:
    try:
        # code to process download here
    except Exception as e:     # most generic exception you can catch
        logf.write("Failed to download {0}: {1}
".format(str(download), str(e)))
        # optional: delete local version of failed download
    finally:
        # optional clean up code
        pass
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #write #error #file
ADD COMMENT
Topic
Name
6+8 =