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 215 views
1 answer 183 views
1 answer 198 views
2 answers 228 views
2 answers 342 views
1 answer 170 views
170 views asked Jul 8, 2020 by avibootz
1 answer 214 views
...