How to append content to a text file in Python

2 Answers

0 votes
with open("d:\\data.txt", "a") as file:
    file.write("\nappended text line")


'''
run:

a
b
c
appended text line

'''

 



answered Oct 21, 2017 by avibootz
0 votes
f = open("d:\data.txt", "a")

f.write("JavaScript")


'''
data.txt
--------
C++
VB.NET
C#
Java
PHP
Python
JavaScript
'''

'''
run:
 

'''

 



answered Nov 26, 2018 by avibootz

Related questions

1 answer 316 views
1 answer 267 views
1 answer 286 views
2 answers 365 views
2 answers 483 views
1 answer 284 views
284 views asked Jul 8, 2020 by avibootz
1 answer 318 views
...