THE WORLD'S LARGEST WEB DEVELOPER SITE

Python File flush() Method

❮ File Methods


Example

You can clear the buffer when writing to a file:

f = open("myfile.txt", "a")
f.write("Now the file has one more line!")
f.flush()
f.write("...and another one!")
Run example »

Definition and Usage

The flush() method cleans out the internal buffer.


Syntax

file.fileno()

Parameter Values

No parameters


❮ File Methods