Home
Q&A
Education
Technology
Credit
General
Health
Insurance
Questions
Ask a Question
How do you append to a file in Python?
asked
Jan 21
in
Education
by
JackTerrance
(
1.8m
points)
Anyone know any special function that appends to the file instead of overwriting it?
Select the correct answer from above options
python
python-faq
append
file
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Jan 21
by
JackTerrance
(
1.8m
points)
Best answer
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
Please
log in
or
register
to add a comment.
Related questions
0
votes
Q: How do I append one string to another in Python?
asked
Feb 3
in
Education
by
JackTerrance
(
1.8m
points)
python
string
append
0
votes
Q: How do I copy a file in Python?
asked
Jan 23
in
Education
by
JackTerrance
(
1.8m
points)
python
filesystem
file
0
votes
Q: What is the difference between Python's list methods append and extend?
asked
Jan 19
in
Education
by
JackTerrance
(
1.8m
points)
python
list
data-structures
append
extend
0
votes
Q: How to check file size in python?
asked
Jan 27
in
Education
by
JackTerrance
(
1.8m
points)
python
file
0
votes
Q: How do I remove/delete a folder that is not empty with Python?
asked
Feb 1
in
Education
by
JackTerrance
(
1.8m
points)
python
file
...