Home >>Python File Methods >Python File tell() Method

Python File tell() Method

Python File tell() Method

Python File tell() Method in python file can be used to returns the current position of the file object /position pointer within the file. This method returns an integer value and takes no parameter.

Syntax:
file.tell()
Here is an example of Python File tell() Method:

 x = open("file1.txt", "r")
print(x.tell())

Output:
0
Example 2:

y= open("file2.txt", "r")
print(y.readline())
print(y.tell())

Output:
Hello! Welcome to file2.txt
32

No Sidebar ads