Web Analytics

Python file.close() Method

File Method โ€ข Close

The close() method closes the file.

You should always close your files, in some cases, due to buffering, changes made to a file may not show until you close the file.

Syntax

file.close()

Parameters

No parameters.

Return Value

None.

Example

Using the close() method:

Output
Click Run to execute your code

Related Functions