如何在不覆盖当前内容的情况下写入文件?
问题描述:
with open("games.txt", "w") as text_file:
print(driver.current_url)
text_file.write(driver.current_url + "\n")
我现在正在使用此代码,但是当它写入文件时,它将覆盖旧内容.我怎么能简单地添加它而不删除已经存在的内容.
I'm using this code right now, but when it writes to the file it overwrites the old content. How can I simply add to it without erasing the content that's already there.