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.flush()
引數值
無引數
寫入檔案時可以清除緩衝區
f = open("myfile.txt", "a")
f.write("Now the file has one more line!")
f.flush()
f.write("...and another one!")
執行示例 »
flush()
方法會清除內部緩衝區。
file.flush()
無引數
如果您想將 W3Schools 服務用於教育機構、團隊或企業,請傳送電子郵件給我們
sales@w3schools.com
如果您想報告錯誤,或想提出建議,請傳送電子郵件給我們
help@w3schools.com