📜  python代码示例中的文件处理模式

📅  最后修改于: 2022-03-11 14:46:09.482000             🧑  作者: Mango

代码示例1
Mode:   Description:
"r"        # Opens a file for reading. (default)
"w"        # Opens a file for writing. Creates a new file if it does not exist or truncates the file if it exists.
"x"        # Opens a file for exclusive creation. If the file already exists, the operation fails.
"a"        # Opens a file for appending at the end of the file without truncating it. Creates a new file if it does not exist.
"t"        # Opens in text mode. (default)
"b"        # Opens in binary mode.
"+"        # Opens a file for updating (reading and writing)