File file objects are created using the open function, and the following table lists the functions commonly used by file file objects:
|Serial number||Method and description|
Close the file. The file can no longer be read and written after it is closed.
Refresh the internal buffer of the file and write the data of the internal buffer directly to the file immediately, instead of passively waiting for the output buffer to write.
Returns an integer file descriptor FD integer that can be used on some underlying operations, such as the read method of the os module.
If the file is connected to a terminal device, true, false is returned.
Returns the next line of the file.
Read the specified number of bytes from the file and read all if not given or negative.
Read the entire line, including the character """
Read all rows and return the list, and if you give sizeint and 0, return a row with a sum of approximately sizeint bytes, the actual read value may be larger than sizeint because the buffer needs to be filled.
Set the current location of the file
Returns the current location of the file.
Intercept the file, the intercepted byte is specified by size, the default is the current file location.
Write the string to the file, returning the length of the character written.
Write a list of sequence strings to the file, and if you need line breaks, add line breaks to each line yourself.