Pickle,读入数据,不支持的pickle协议:3 python 2.7 [英] Pickle , read in data , unsupported pickle protocol: 3 python 2.7
本文介绍了Pickle,读入数据,不支持的pickle协议:3 python 2.7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里是初学者,想读入以 p 结尾的数据.
Beginner here, want to read in data with the file ending p.
我的代码如下:
import pickle
training_file = "/home/sk/CarND-Traffic-Sign-Classifier-Project/train.p"
testing_file = "/home/sk/CarND-Traffic-Sign-Classifier-Project/test.p"
with open(training_file, mode='rb') as f:
train = pickle.load(f)
with open(testing_file, mode='rb') as f:
test = pickle.load(f)
我收到以下错误:
ValueError: 不支持的泡菜协议:3
ValueError: unsupported pickle protocol: 3
有人可以指出我如何修复它,无论是更改协议还是以其他方式读取数据?
Can someone point out how i can fix it, either changing protocol or reading in the data some other way ?
推荐答案
当我使用 python3 创建一个 pickle 文件然后尝试在 python2 中加载它时遇到了同样的问题.尝试使用 python3 运行您的程序或尝试使用 python2 创建一个 pickle 文件.
Had the same issue when i created a pickle file using python3 and then tried loading it in python2. Try running your program with python3 or try creating a pickle file using python2.
这篇关于Pickle,读入数据,不支持的pickle协议:3 python 2.7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文