Python File tell() Method

Example

Find the current file position:

f = open("demofile.txt", "r")
print(f.tell())

Run Instance

Definition and Usage

The tell() method returns the current file position in the file stream.

Tip:You can change the current file position with the seek() method.

Syntax

file.tell()

Parameter values

No parameter values.

More Examples

Example

After reading the first line, return the current file position:

f = open("demofile.txt", "r")
print(f.readline())
print(f.tell())

Run Instance