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 219 views
1 answer 188 views
1 answer 206 views
2 answers 234 views
2 answers 348 views
1 answer 177 views
177 views asked Jul 8, 2020 by avibootz
1 answer 216 views
...