Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
208 views
in Technique[技术] by (71.8m points)

python - 如何在Python中附加文件?(How do you append to a file in Python?)

How do you append to the file instead of overwriting it?

(您如何附加到文件而不是覆盖文件?)

Is there a special function that appends to the file?

(有附加到文件的特殊功能吗?)

  ask by translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
with open("test.txt", "a") as myfile:
    myfile.write("appended text")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...