Python file operation Seek () and telll () self-explanatory

Source: Internet
Author: User

Python file operation Seek () and telll () self-explanatory

File.seek () method format: Seek (offset,whence=0) Move file read pointer to set position

Offset: The starting offset, which represents the number of bytes that need to move the offset.

Whence: A definition of the offset parameter that indicates which position to start the offset from, 0 for the beginning of the file, 1 for starting from the current position, and 2 for starting from the end of the file.                         When there is a newline, it is truncated by line breaks. Seek () No return value, so the value is None

Tell (): The current position of the liberal arts file, that is, tell is to get the file pointer position.

ReadLine (N): reads in several rows, and n represents the maximum number of bytes read in.

ReadLines (): reads the contents of all rows

Read reads the contents of all rows

Tell (): Returns the location of the file read pointer

The main 3 modes of Seek are:

(1) F.seek ()

 

Python file operation Seek () and telll () self-explanatory

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.