tell()

fob.tell()
Returns the current position of the file object.

In text mode file reading ( r )

At the beginning of the file.
fob=open('data1.txt','r')
print(fob.tell()) # 0 

Using write mode

After writing data , the object will be at the end.
fob=open('data3.txt','w')
fob.write("Hello")
print(fob.tell()) # 5
fob.close()
We will add offset by using seek()
fob=open('data.txt','r')
fob.seek(5)
print(fob.tell()) # 5 
By using the data.txt file given at file read()
fob=open('data.txt','br')
fob.seek(-5,2)
print(fob.tell()) # 76
fob=open('data.txt','r')
print(fob.readline())
print(fob.tell())
fob.close()
Output
This is first line

20
Moving the file position by seek()

File Append File Write
Subscribe to our YouTube Channel here

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2022 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer