seek and tell function in the python

technical talkiess
0

 print("File handling")


# only write the file and override the existing content of the file
# f = open("test.txt","w")
# f.write("test")
# this content adding in the new line of the file and not override the file
# f = open("test.txt","a")
# f.write("This is the new text\n")

f = open("test.txt")
# f.write("This is the new text\n")
# content = f.read()

# agar apko file pointer kaha par hai wo dekhna hai to tell function a use kar sakte hai in the python

print(f.tell())
print(f.readline())

# agar apko file pointer ko reset krna hai to aap seek function ka use kar sakte hai in the python... seek(4) matlab aap apka pointer 4 se cha;u hoga

f.seek(4)

print(f.tell())
print(f.readline())


print(f.tell())
print(f.readline())

f.close()
Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)