Python Tutorial Python Advanced Python Resources Python Libraries
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

Python - File seekable() Method



The Python file seekable() method is used to check whether the file is seekable or not. It returns true when the file is seekable, else returns false. A file is seekable if it allows access to the file stream, like the seek() method.

Syntax

file.seakable()

Parameters

No parameter is required.

Return Value

Returns True if the file is seekable, else returns False.

Example:

In the example below, the file seekable() method is used to check whether the file test.txt is seekable or not.

MyFile = open("test.txt", "w")

print(MyFile.seekable())

The output of the above code will be:

True

❮ Python File Handling Methods

5