首页 > 解决方案 > UnicodeDecodeError: 'ascii' codec can't decode byte 0xcc in position 0: ordinal not in range(128)

问题描述

I use Python3.6 and this code occurs error

with open('val_image_id2feature.pkl', 'rb') as f:
    val_image_id2feature = pickle.load(f)

UnicodeDecodeError: 'ascii' codec can't decode byte 0xcc in position 0: ordinal not in range(128)

if I add encoding='latin1' or encoding='bytes' as follows, new issues occur

with open('val_image_id2feature.pkl', 'rb') as f:
    val_image_id2feature = pickle.load(f, encoding='latin1')

_pickle.UnpicklingError: pickle data was truncated

How to deal with it?

标签: python-3.xencodingpickle

解决方案


推荐阅读