python-3.x - 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?
解决方案
推荐阅读
- django - 如何仅在 websocket 上本地显示数据
- windows - VScode终端的PATH环境变量与cmd不同
- http - 接收方是否可以减少 HTTP/2 流控制窗口?
- sql - 如何使用 ODBC 包从 R 更改 SQL 表的变量类型?
- networking - 电路交换与虚电路交换
- python - 字符串的 Numba 矢量化:NotImplementedError:unicode_type 不能表示为 Numpy dtype
- java - Java中的默认超类
- javascript - 如何使用 mysql 模块在没有 ORM 的情况下访问 Nodejs 类中的数据库实例
- javascript - 调整足球间距以填充屏幕 - React/CSS
- coq - 如何在 Coq 中对重复的假设进行分组?