Seek(), tell() & More On Python Files

 #30



# f= open("aryan.txt")
# print(f.tell())
# print(f.readline())
# print(f.tell())
# print(f.readline())
# print(f.tell())
# print(f.readline())

# f.close()
#Seek is used to determine from where to read for ex if we type 0 so it will read from 0 character and so on.

f= open("aryan.txt")
print(f.readline())
f.seek(11)
print(f.readline())

#31
Using With Block
with open("aryan.txt") as f:
a= f.readlines()
print(a)


Comments

Popular posts from this blog

Practice Execise 3

Pickle Module