python 3.4中,'gbk' codec can't decode byte 0x80 in position 0

本人使用python3.4,win764位操作系统,当
6"""loadsinglebatchofcifar"""
7withopen(filename,'r')asf:
---->8datadict=pickle.load(f)
9X=datadict['data']
错误信息是UnicodeDecodeError:'gbk'codeccan'tdecodebyte0x80inposition0:illegalmultibytesequence
我把line7改成了
6"""loadsinglebatchofcifar"""
7withopen(filename,'r',encoding='utf-8")asf:
---->8datadict=pickle.load(f)
9X=datadict['data']
311#decodeinput(takingthebufferintoaccount)
312data=self.buffer+input
-->313(result,consumed)=self._buffer_decode(data,self.errors,final)
314#keepundecodedinputuntilthenextcall
315self.buffer=data[consumed:]
错误的最终指向了Python34\lib\codecs.pyindecode(self,input,final)。
错误信息是UnicodeDecodeError:'utf-8'codeccan'tdecodebyte0x80inposition0:invalidstartbyte。
请问具体是编解码哪块出了问题,怎么解决?
哔哔one
浏览 429回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript