学习笔记:第二天

文件操作

with open('day2','w',encoding='utf-8') as f:
f.write('ndjafnglsf马翁')
with open('day2','r+',encoding='utf-8') as e:
print(e.read())
data = e.truncate(4)
print(data)
with open('day2','rb')as g:
h =g.read()
print(h)
print(h.decode('utf-8'))
with open('day2','wb')as i :
i.write(bytes('阿瑟东',encoding='utf-8'))
with open('day2','r',encoding='utf-8') as e:
print(e.read())
e.seek(3)
print(e.tell())

猜你喜欢

转载自www.cnblogs.com/mwb1112/p/9906129.html