python - 使用莳萝负载时出现 UnicodeDecodeError
问题描述
我正在尝试使用 dill.load 加载模型但得到 UnicodeDecodeError。
BASEDIR = './raw/data/'
modelfile = 'xyz.pkl'
model = dill.load(open('%s%s' % (BASEDIR, modelfile), 'rb'))
错误:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc6 in position 0: ordinal not in range(128)
我尝试encoding='utf-8'
根据其他可用答案添加,但随后出现 ValueError:
ValueError: binary mode doesn't take an encoding argument
locale
在我的 conda 环境终端中的输出:
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
我正在使用 python 3.7
解决方案
推荐阅读
- rstan - 关于 SBC 函数 rstan::sbc
- angular - Angular 8 和 ng2 图表 - 更新标签和数据
- regex - 如何使用python3中的re模块按不同组获取一些数字
- list - Flutter 中的 AnimatedList 显示破碎的元素
- javascript - 如何在链接单击而不是打开时下载图像
- android - 如何使用带有导航的 CollapsingLayout 高级示例
- python - Anaconda Python 的 shebang 是什么?
- bash - 我应该如何使用 linux `find` 命令搜索一组文件?
- c - “C中的参数”的定义是什么
- linux - mmap 文件上的 fallocate 会减少内存消耗吗?