seek() and tell() functions on files in Python

 

f = open("file_name.txt")
print(f.seek(55)) #resets reading from 55th character
print(f.readline(), end="")
print(f.tell()) #shows where the file pointer currently is
print(f.readline(), end="")
print(f.tell()) #shows where the file pointer currently is
print(f.readline(), end="")
print(f.tell()) #shows where the file pointer currently is
f.close()




Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

Using insertAdjacentHTML instead of innerHTML to avoid XSS attacks

Guess The Number Game - You vs. Your Friend