我注意到,在Python中写入文件时,一旦文件关闭,内容就会写入文件中。
例如:
with open('test.txt','w') as ffile: ffile.write("testing") time.sleep(20)
在此示例中“等待 20 秒后将写入“ testing ”。
这是如何以及为何发生的?为什么不同时写入文件呢?
python file-io file python-3.x
file ×1
file-io ×1
python ×1
python-3.x ×1