Python - File readable() Method


Advertisements

The Python file readable() method is used to check whether the specified file is readable or not. It returns true if the specified file is readable, else returns false.

Syntax


file.readable()

Parameters

No parameter is required.

Example: Check a file, readable or not

In the below example, Python file readable() method is used to check whether the file called MyFile is readable or not. As it is a readable file, it returns True.

MyFile = open("python_test.txt")
print(MyFile.readable())

Output

True

Python File Handling Methods
Advertisements