The tell method in the for loop returns an error when the Python file is read

The

code iterates one line at a time, expecting the tell method to return the position of the current pointer. But what is actually returned is the last location of the entire document;
Please help me to see what the problem is?

My Daily.txt

Good morning:
    As we known, Chengdu IS one of largest cities in the world!
    Set up
    get up
    take off
OK

the code is as follows

with open(r"My Daily", "r+") as f:
    for line in f:
        print f.tell()
Mar.15,2021

when using for traversal on the file object f, the contents of f are read out and iterable objects are generated for traversal.

so your output is always at the end


for line in f:
is when the f.next ().
f.next () method is called, the f.tell () method cannot be called

if you need to return the current pointer position, you can do this
pos = 0
with open (r'My Daily', 'ringing') as f:

for line in f:
    pos += len(lien)
    -sharpprint f.tell()
    print(post)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e97196-1628.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e97196-1628.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?