+2 votes
in Programming Languages by (7.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

0 votes
by (15.1k points)

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")
 

...