Python write to file without overwriting current txt
本问题已经有最佳答案,请猛点这里访问。
1 2 3 4 | with open("games.txt","w") as text_file: print(driver.current_url) text_file.write(driver.current_url +" ") |
我现在正在使用这个代码,但是当它写入文件时,它会覆盖旧的内容。我怎样才能简单地添加到其中而不删除已经存在的内容呢?
使用带
1 | with open("games.txt","a") as text_file: |