文件处理的b模式
f=open(‘test11.py‘,‘rb‘,encoding=‘utf-8‘) #b的方式不能指定编码 f=open(‘test11.py‘,‘rb‘) #b的方式不能指定编码 data=f.read() #‘字符串‘---------encode---------》bytes #bytes---------decode---------》‘字符串‘ print(data) print(data.decode(‘utf-8‘)) f.close()
原文:https://www.cnblogs.com/augustyang/p/9047205.html