b模式处理文件

1、读

f=open('cheng','rb')
date=f.read()
print(date.decode())

 

 

2、写

f=open('cheng','ab')
f.write('chengzhengdong'.encode('utf-8'))
f.close
f=open('cheng','ab')
f.write(bytes("chengzhengdong",encoding="utf-8"))
f.close

 

posted @ 2018-09-06 14:31  chengzhengdong  阅读(91)  评论(0编辑  收藏  举报