代码示例:(标识:demo_python_ref_file_flush)
demo_python_ref_file_flush.py
f = open("myfile.txt", "a")
f.write("Now the file has one more line!")
f.flush()
f.write("...and another one!")
运行结果: