1. 程式人生 > >學習筆記:第二天

學習筆記:第二天

檔案操作

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())