English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
tell() The method returns the current position of the file, that is, the position of the file pointer.
Syntax of tell() method:
fileObject.tell()
None
Return the current position of the file.
The following example demonstrates the use of the tell() method:
File w3The content of codebox.txt is as follows:
1:fr.oldtoolbag.com 2:fr.oldtoolbag.com 3:fr.oldtoolbag.com 4:fr.oldtoolbag.com 5:fr.oldtoolbag.com
Loop to read the content of the file:
# Open the file fo = open("w3codebox.txt", "r") print("The file name is: ", fo.name) line = fo.readline() print("The data read is: %s" % (line)) # Get the current file position pos = fo.tell() print("Current location: %d" % (pos)) # Close the file fo.close()
The output result of the above example is:
The file name is: w3codebox.txt The data read is: 1:fr.oldtoolbag.com Current location: 17