Python File tell() Method

❮ File Methods


Example

Find the current file position:

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

Definition and Usage

The tell() method returns the current file position in a 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

Return the current file position after reading the first line:

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

❮ File Methods

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.