python - How can I write on new lines in a text file while preserving old ones -
when open text file , write in , @ end of program close it, lines stay in text file. when reopen program, rather writing on new set of lines, overwrites there. want keep both pieces of text, data logging. ideas on how fix this.
you should use a
mode, this:
with open("file","a") f: f.write("something")
this append file instead of overwriting it.
Comments
Post a Comment