+2 votes
in Programming Languages by (14.6k 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 (25.6k 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")