您可以在写入文件时清除缓冲:
f = open("myfile.txt", "a")f.write("Now the file has one more line!")f.flush()f.write("...and another one!")
f = open("myfile.txt", "a")
f.write("Now the file has one more line!")
f.flush()
f.write("...and another one!")
flush() 方法清除内部缓冲。
flush()
file.fileno()
无参数。