What is the purpose of seek() function?
Answer:
The seek( ) method is used to position the file object at a particular position in a file.
The syntax of seek() is:
file_object.seek(offset , [reference_point])
In the above syntax,
- offset is the number of bytes by which the file object is to be moved .
- reference_point indicates the starting position of the file object . That is, with reference to which position, the offset has to be counted.
It can have any of the following values:
- 0 - beginning of the file
- 1 - current position of the file
- 2 - end of file
- Default value of reference_point is 0.