如何在while循环中的每次迭代中更新文件更改?

时间:2019-03-31 13:37:55

标签: python python-3.x while-loop

我试图为我的python程序连续更新文件,所以我正在使用while循环。我的代码是:

while True:
    with open("load.html", "w") as dataFile:
        dataFile.write("Information")
        dataFile.close()

下面的代码虽然可以正常工作,但在每次编辑后不会更新,但会在while循环或程序中断/结束后加载。我该如何做,以使while循环的每次迭代都更新文件中的每次编辑。 (我想每次替换以前的数据。)

0 个答案:

没有答案