Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pickle 报错 #7

Open
ZHAIXINGZHAIYUE opened this issue May 3, 2018 · 1 comment
Open

pickle 报错 #7

ZHAIXINGZHAIYUE opened this issue May 3, 2018 · 1 comment

Comments

@ZHAIXINGZHAIYUE
Copy link

您好,您用的pickle模块的版本号是多少?
我在执行这一句时
self.data_dict = pickle.load(file)
遇到错误
·UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 0: illegal multibyte sequence·

@erikgajdos
Copy link

erikgajdos commented May 3, 2018

Hello, are you using python 3? If yes, there is some pickle between python version problem.
Instead of
self.data_dict = pickle.load(file)

Please try this code:

with open('path/to/your/pickle/file','rb') as file: # Binary read
            u = pickle._Unpickler(file)
            u.encoding = 'latin1'
            p = u.load()
            self.data_dict = p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants