UnicodeDecodeError: 'gbk'编解码器无法解码字节
我正在尝试使用pickler从文件中加载一个对象(自定义类Area)。我正在使用 python 3.1。
该文件是使用 pickle.dump(area, f)
创建的,
我收到以下错误,我希望帮助尝试理解和修复它。
文件“editIO.py”,第 12 行,加载中 area = pickle.load(f)
文件“C:\Python31\lib\pickle.py”,第 1356 行,加载中 编码=编码,错误=错误).load()
UnicodeDecodeError:“gbk”编解码器无法解码位置0-1中的字节:非法多字节序列
I'm trying to load an object (of a custom class Area) from a file using pickler. I'm using python 3.1.
The file was made with pickle.dump(area, f)
I get the following error, and I would like help trying to understand and fix it.
File "editIO.py", line 12, in load
area = pickle.load(f)
File "C:\Python31\lib\pickle.py", line 1356, in load
encoding=encoding, errors=errors).load()
UnicodeDecodeError: 'gbk' codec can't decode bytes in position 0-1: illegal multibyte sequence
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果不显示代码,很难说,但看起来您使用“gbk”编码以文本模式打开了文件。它可能应该以二进制模式打开。如果没有发生这种情况,请制作一个失败的小代码示例,并将其粘贴到此处。
It's hard to say without you showing your code, but it looks like you opened the file in text mode with a "gbk" encoding. It should probably be opened in binary mode. If that doesn't happen, make a small code example that fails, and paste it in here.