【文件操作基础流程】

【文件操作基础流程】


能调用的方法一定是对象 ┍ ┎ ┏ ┐ ┑ ┒ ┓ ─ ┄ ┼ ┼ │ ┌
li=[1,2,3]
li.append('2')


.read #读取模式
.write#写模式
                
f=open('wl','r',encoding='utf8') #打开文件wl      'r'读取模式                     字符编码转'UTF8'
date=f.read()
print(date)
f.close() '关闭文件'


f=open('wl','w',encoding='utf8') #打开文件wl 'write'(删除原有)并写入模式 字符编码转'UTF8'
date=f.write()
print(date)
f.close() '关闭文件'



f=open('wl', 'a',encoding='utf8') #打开文件wl 'a'代表追加写人模式 字符编码转'UTF8'

猜你喜欢

转载自www.cnblogs.com/djkofwl/p/9500883.html
今日推荐