Python在不覆盖当前tx的情况下写入文件

2024-05-20 04:39:26 发布

您现在位置:Python中文网/ 问答频道 /正文

with open("games.txt", "w") as text_file:
    print(driver.current_url)
    text_file.write(driver.current_url + "\n")

我现在正在使用这段代码,但是当它写入文件时,它会覆盖旧的内容。我怎么能简单地添加到它而不删除已经存在的内容。


Tags: 文件代码texttxturl内容asdriver