小编Hao*_*oyu的帖子

UnicodeDecodeError:'gbk'编解码器无法解码位置0非法多字节序列中的字节0x80

我使用python 3.4和win 7 64位系统.我运行了以下代码:

      6   """ load single batch of cifar """
      7   with open(filename, 'r') as f:
----> 8     datadict = pickle.load(f)
      9     X = datadict['data']
Run Code Online (Sandbox Code Playgroud)

错误的信息是 UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 0: illegal multibyte sequence

我将第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']
Run Code Online (Sandbox Code Playgroud)

错误的信息变成了UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte. …

python encoding pickle

3
推荐指数
2
解决办法
2万
查看次数

标签 统计

encoding ×1

pickle ×1

python ×1