How do you append to a file in Python?

user502039 picture user502039 · Jan 16, 2011 · Viewed 1.7M times · Source

How do you append to the file instead of overwriting it? Is there a special function that appends to the file?

Answer

Petter picture Petter · Jan 16, 2011
with open("test.txt", "a") as myfile:
    myfile.write("appended text")