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 |
---|---|
1 |
Close the file. The file can no longer be read and written after it is closed. |
2 |
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. |
3 |
Returns an integer file descriptor FD integer that can be used on some underlying operations, such as the read method of the os module. |
4 |
If the file is connected to a terminal device, true, false is returned. |
5 |
Returns the next line of the file. |
6 |
Read the specified number of bytes from the file and read all if not given or negative. |
7 |
Read the entire line, including the character """ |
8 |
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. |
9 |
Set the current location of the file |
10 |
Returns the current location of the file. |
11 |
Intercept the file, the intercepted byte is specified by size, the default is the current file location. |
12 |
Write the string to the file, returning the length of the character written. |
13 |
Write a list of sequence strings to the file, and if you need line breaks, add line breaks to each line yourself. |