+2 votes
in Programming Languages by (77.8k points)
I want to open a file in append mode so that I can add records to this file in different functions present in my program. How to append new records to a file instead of rewriting?

1 Answer

+1 vote
by (355k points)
selected by
 
Best answer

You can use 'a' in the open() function to open a file in append mode. Check the below example.

with open("myfile", "a") as fl:

    fl.write("your data")
 

Related questions


...