Python basic file operations

A, Python file operations


 

Python file operations have r, w, a, r +, w +, a + and the like, as shown below:

 Precautions: r +, w +, a + are to read and write files, then what are their differences

(1) r + overwrites the current file pointer position where the characters, such as 'hello world', write open file 'egon', the file content becomes 'egon world';

(2) the content of the original document will open when w + empty file

(3) a + is the current file pointer regardless of where new content is written from the end of the file

Second, the relevant method Python file reads


 

The method of operation of common file are read (), write (), readline (), readlines (), close (), seek (), tell (), etc.

As shown below:

 

Guess you like

Origin www.cnblogs.com/surpass123/p/12427863.html