Python 文件 flush() 方法

實例

您可以在寫入文件時清除緩沖:

f = open("myfile.txt", "a")
f.write("Now the file has one more line!")
f.flush()
f.write("...and another one!")

運行實例

定義和用法

flush() 方法清除內部緩沖。

語法

file.fileno()

參數值

無參數。