码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-12-17 14:16:53      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:开头   nbsp   end   生成   read   bin   清空   只读   二进制   

      文件操作的几种模式:

"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 ,追加写,写在原文件的后面,从文件的结尾写入

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

标签:开头   nbsp   end   生成   read   bin   清空   只读   二进制   

原文地址:https://www.cnblogs.com/whitemouseV2-0/p/10130742.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!