Several types of Python open documents

Open in read-only mode, the pointer of the file stops at the beginning of the file

parameter meaning
w Open the file for writing, (behind the written code), if the file exists, overwrite the content of the file, if the file does not exist, create a new file for storage
a Open the file for appending, inherit the characteristics of w (a will not be overwritten when the file exists), the appended content will be added at the end of the text
rb Open the file in binary mode for read-only. (The rest is the same as r)
wb Open and write in binary mode. (The rest is the same as w)
from Append in binary mode. (The rest is the same as a)
r+ Open the file for reading and writing. (The rest is the same as r)
w+ Open the file for reading and writing. (The rest is the same as w)
a+ Open the file for reading and writing. (The rest is the same as a)
rb+ Open in binary for reading and writing. The file pointer is placed at the beginning of the file.
wb+ Open in binary for reading and writing. (The rest is the same as w)
from + Open in binary for appending. (The rest is the same as a)

 

 

Guess you like

Origin blog.csdn.net/someby/article/details/105057126