python 3.4 gbk编码问题求助,pythongbk,本人使用python 3
python 3.4 gbk编码问题求助,pythongbk,本人使用python 3
本人使用python 3.4,win7 64位操作系统,当
6 """ load single batch of cifar """ 7 with open(filename, 'r') as f:----> 8 datadict = pickle.load(f) 9 X = datadict['data']
错误信息是UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 0: illegal multibyte sequence
我把line 7 改成了
6 """ load single batch of cifar """ 7 with open(filename, 'r',encoding='utf-8") as f:----> 8 datadict = pickle.load(f) 9 X = datadict['data'] 311 # decode input (taking the buffer into account) 312 data = self.buffer + input--> 313 (result, consumed) = self._buffer_decode(data, self.errors, final) 314 # keep undecoded input until the next call 315 self.buffer = data[consumed:]
错误的最终指向了 Python34\lib\codecs.py in decode(self, input, final)。
错误信息是UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte。
请问具体是编解码哪块出了问题,怎么解决?
http://www.crifan.com/summary_python_unicodedecode_error_possible_reasons_and_solutions/
pywith open(filename, 'rb') as f:
pickle(除了最早的版本外)是二进制格式的,所以你应该带 'b' 标志打开文件。
编橙之家文章,
相关内容
- 为什么我的web.pydb.select返回的数据只能遍历一次?怎么解
- Python3.5想把抓到的股票信息以循环方式存入到csv文件中
- Python语言能完成检索Twitter搜索功能吗?,pythontwitter,看社
- 我的python正则表达式写的对吗,python正则表达式,Html源
- Python如何在网页上呈现数据库的值并做到有翻动效果,
- python *乘号在命令行中为什么报错,python乘号,环境Mac
- beautifulsoup3.2.1使用时遇到的一些小问题,,参考了文档
- 谁能分享Python OpenStack高质量的部署资料,pythonopenstac
- 参照教程的Flask操作显示AttributeError是什么问题,,Flas
- 只有python2.6o可以在sx版本mod_wsgi中使用吗?,python2.6omo
评论关闭