拾取和取消对象的正常方法如下:
挑选一个对象:
import cloudpickle as cp
cp.dump(objects, open("picklefile.pkl", 'wb'))
UnPickle一个对象:(加载pickle文件):
loaded_pickle_object = cp.load(open("picklefile.pkl", 'rb'))
现在,如果将pickle对象托管在服务器中,例如google驱动器,该怎么办?如果我直接在路径中提供该对象的URL,我就无法取消对象。以下是行不通的:我得到IOERROR
UnPickle一个对象:(加载pickle文件):
loaded_pickle_object = cp.load(open("https://drive.google.com/file/d/pickled_file", 'rb'))
有人能告诉我如何将pickle文件加载到Web URL中托管的python中吗?
答案 0 :(得分:2)
将gdrive腌制的文件导入Python 3合作实验室时,以下内容对我有用:
from urllib.request import urlopen
loaded_pickle_object = cp.load(urlopen("https://drive.google.com/file/d/pickled_file", 'rb'))