【发布时间】:2020-02-12 17:08:32
【问题描述】:
"what exactly the python's file.flush() is doing?" 表示您应该先f.flush() 然后os.fsync(f) 以确保将数据写入磁盘。
此外,"does close() imply flush() in Python?" 声称f.close() 意味着flush()。
现在的问题是:我应该这样做
os.fsync(f)
f.close()
或者,f.close() 是否也意味着os.fsync()?
这里是doc of Python IO、doc of Python file close 和source code。快速搜索“fsync”没有返回相关信息。
【问题讨论】:
-
可能所有人都只使用
f.close(),并且没有人对保存的数据有任何问题。 -
@furas 是的。但是,当
close()返回时,我可以确定我的数据已完成保存到云端硬盘吗?