Write open(fildname, "a") The second factor in open is related to the mode of reading and writing files.
The difference between r+
and a+
is in current look position
.
If you open it with r+
and write it right away, write it from the front of the file
If you open it with a+
and write it right away, write it from the back of the file.
with open("test.txt", "a") as myfile:
myfile.write("appended text")
© 2024 OneMinuteCode. All rights reserved.