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