Back

Explore Courses Blog Tutorials Interview Questions
+3 votes
8 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 (106k 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
1 answer
0 votes
2 answers
0 votes
1 answer
asked Jul 22, 2019 in Python by Eresh Kumar (45.3k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.6k users

Browse Categories

...