1. Open File
Open (file, mode= ' R ', Buffering=-1, Encoding=none, Errors=none, Newline=none, Closefd=true, Opener=none)
2. Close the file
Close (): Be sure to close the file after the file operation, Python can not be closed, because Python has an automatic garbage collection mechanism.
3. File read
Read (SIZE=-1): reads a size character from a file, reads the remaining characters when not given a size or a given negative value, and then returns as a string. Read () continues reading by default from the last read
ReadLine (): reads a row
4. File Write
Write (str): Writes the string str to the file
Writelines (seq): Want a file to be written to a string sequence seq,seq should be an iterative object that returns a string
5. Move the file pointer
Seek (Offset,from): Move a file pointer in a file, starting from (0 for the starting position of the file, 1 for the current position, and 2 for the end of the file) to start offsetting offset bytes
Tell (): Returns the current location of the file
Python file operations