【发布时间】:2020-07-15 22:09:20
【问题描述】:
from re import findall
output = 0
f = open("100$ School.txt", "w+")
f.write(str(output))
我的目标是让它每次运行时都会在新行中写入。 感谢任何花时间来遮阳篷的人
【问题讨论】:
-
你的问题是什么?
标签: python python-3.x file file-io
from re import findall
output = 0
f = open("100$ School.txt", "w+")
f.write(str(output))
我的目标是让它每次运行时都会在新行中写入。 感谢任何花时间来遮阳篷的人
【问题讨论】:
标签: python python-3.x file file-io
你可以试试这个。
with open("100$ School.txt", "w+") as f:
f.write(str(output)+"\n")
【讨论】:
您需要附加它才能不被覆盖。所以w+ 必须是a+
from re import findall
output = 0
f = open("100$ School.txt", "a+")
f.write(str(output)+"\n")
【讨论】:
试试这个:
f = open("100$ School.txt", "a+") # "a+" for append
f.write(f"{output}\n")
【讨论】: