Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+3 votes
9 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)
edited by

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:-

Be a Python Expert. Enroll in Python Training by Intellipaat.

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)

Browse Categories

...