snippetpythonCriticalCanonical
How do I append to a file?
Viewed 0 times
appendhowfile
Problem
How do I append to a file instead of overwriting it?
Solution
Set the mode in
The documentation lists all the available modes.
open() to "a" (append) instead of "w" (write):with open("test.txt", "a") as myfile:
myfile.write("appended text")
The documentation lists all the available modes.
Context
Stack Overflow Q#4706499, score: 3175
Revisions (0)
No revisions yet.