Answers for "python try except write error to file"

0

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}n".format(str(download), str(e)))
        # optional: delete local version of failed download
    finally:
        # optional clean up code
        pass
Posted by: Guest on November-19-2020

Code answers related to "python try except write error to file"

Python Answers by Framework

Browse Popular Code Answers by Language