tell()
tell()
returns the current position of the file pointer from the beginning of the file.
f = open("demofile.txt", "r")# points at the startprint(f.tell())
seek()
If we want to move the file pointer to another position, we can use the seek()
method.
This method takes two arguments:
offset
represents how many bytes to movefromwhere
, represents the position from where the bytes are moving.f = open("demofile.txt", "r")f.seek(4)print(f.readline())