python之文件操作的几种模式总结

      文件操作的几种模式:

"w"                             #write ,清空写,生成一个新的文件,写入内容,覆盖原文件
"w+"                           #write and read ,先清空文件,然后写入内容,最后才能读取写入的内容
"wb"                           #write binary #,b表示二进制模式读写
"r"                              #read ,只读
"rb"                            #read binary ,b表示二进制模式读写
"r+"                             #read and write ,不清空原文件内容,可以同时读和写,从文件的开头写入
"a"                             #append ,追加写,写在原文件的后面,从文件的结尾写入
"ab"                           #append binary ,b表示二进制模式读写
"a+"                          #append and read ,追加写,写在原文件的后面,从文件的结尾写入

猜你喜欢

转载自www.cnblogs.com/whitemouseV2-0/p/10130742.html