4.python3.x TypeError: must be str, not bytesmust be str, not bytes

python3中使用open(shoplistfile,'w')  open(shoplistfile,'r')报错

使用的python3.x,报错TypeError: must be str, not bytes,然后将open(shoplistfile,'w')和open(shoplistfile,'r')分别改成了open(shoplistfile,'wb')和open(shoplistfile,'rb'),就成功了额。

百度了下说是:pickle(除了最早的版本外)是二进制格式的,所以你应该带 'b' 标志打开文件。



转载:
https://www.jianshu.com/p/487057d8ab5d

你可能感兴趣的:(4.python3.x TypeError: must be str, not bytesmust be str, not bytes)