I need to add my program's outputs to a saved file every time I run the program without overwriting the previous outputs.
This is how I'm writing to a file now:
lead.write(str(alldates))
Any ideas?
I need to add my program's outputs to a saved file every time I run the program without overwriting the previous outputs.
This is how I'm writing to a file now:
lead.write(str(alldates))
Any ideas?
Here, you should open
the file in a
ppend mode:
append_text = str(alldates)
with open('my_file.txt', 'a') as lead:
lead.write(append_text)
There are lots of specialised ways to open
files for different purposes, and you can read about them in the documentation.