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.flush()

Parameter Values

No parameters


❮ File Methods

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.