The seekable() method from the File Methods in Python is used to check if the file is in a seekable mode. It returns True if the file is seekable, meaning that the file supports random access using methods like seek() and tell(); otherwise, it returns False.
Parameter Values
This function does not accept any parameters.Return Values
The seekable() method returns a bool indicating if the file supports seeking.
How to Use seekable() in Python
Example 1:
The seekable() method checks if the file stream supports random access (seeking). It returns True if the file stream is seekable and False otherwise.
file = open('example.txt', 'r')
print(file.seekable())
file.close()