Python關閉它們時自動重新整理檔案。 但你可能要關閉檔案之前重新整理資料。
fileObject.flush()
NA
#!/usr/bin/python3 # Open a file fo = open("foo.txt", "wb") print ("Name of the file: ", fo.name) # Here it does nothing, but you can call it with read operation. fo.flush() # Close opend file fo.close()
Name of the file: foo.txt