小码哥的IT人生

Python 文件 flush() 方法

Python基础 2022-06-06 16:18:12小码哥的IT人生shichen

Python 文件 flush() 方法

实例

您可以在写入文件时清除缓冲:

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() 方法清除内部缓冲。

语法

file.fileno()

参数值

无参数。

版权所有 © 小码哥的IT人生
Copyright © phpcodeweb All Rights Reserved
ICP备案号:苏ICP备17019232号-2  

苏公网安备 32030202000762号

© 2021-2024