+3 votes
2 views
in Python by (3.5k points)
Anyone know any special function that appends to the file instead of overwriting it?

2 Answers

0 votes
by (2k points)
edited by

Yes, Just perform this syntax:

with open("test.txt", "q") as myfile:
    myfile.write("appended text")

 or

f = open('filename.txt', 'q')
f.write("stuff")
f.close()

Happy Learning  

0 votes
by (107k points)

You can do this,

f = open('filename.txt', 'a')

f.write("stuff")

f.close()

It's simple but very useful.

You can use the following video tutorials to clear all your doubts:-

Related questions

0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
asked Aug 23 in Python by Sammy (47.7k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...