Check sibling questions

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.

Introducing your new favourite teacher - Teachoo Black, at only ₹83 per month

CA Maninder Singh's photo - Expert in Practical Accounts, Taxation and Efiling

Made by

CA Maninder Singh

CA Maninder Singh is a Chartered Accountant for the past 12 years. He also provides Accounts Tax GST Training in Delhi, Kerala and online.