English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Python basic tutorial

Python flow control

Fonctions en Python

Types de données en Python

Python file operations

Python objects and classes

Python date and time

Advanced knowledge of Python

Python reference manual

Python file seekable() usage and example

Python File (File) methods

Overview

seek() The method is used to check if the file is searchable.

Syntax

The syntax of the seekable() method is as follows:

file.seekable()

Parameters

  • No parameters

Return value

If the file is searchable, the seekable() method returns True, otherwise it returns False.
If the file allows access to the file stream (such as the seek() method), then the file is searchable.

Example

The following example demonstrates the use of the seekable() method, to check if the file is searchable:

f = open("w3codebox.txt", "r")
print(f.seekable())

The output result of the above example is as follows:

True

Python File (File) methods