2024-05-20 04:39:26 发布
网友
with open("games.txt", "w") as text_file: print(driver.current_url) text_file.write(driver.current_url + "\n")
我现在正在使用这段代码,但是当它写入文件时,它会覆盖旧的内容。我怎么能简单地添加到它而不删除已经存在的内容。
使用^{}函数的"a"(append)模式代替"w":
"a"
"w"
with open("games.txt", "a") as text_file:
使用^{} 函数的
"a"
(append)模式代替"w"
:相关问题 更多 >
编程相关推荐