Python

Python Menu

Python

Python File close() - Definition, Syntax, Parameters, Examples

Definition

The close() method closes an open 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.

Example:

f = open("myFile.txt", "r")
print(f.read())
f.close()

Introduction

Python Basics

Python Advance

Data Science Python Tutorials

Python Functions and Methods