ValueError: insecure string pickle

后端 未结 10 1540
轻奢々
轻奢々 2020-12-03 04:00

When I am trying to load something I dumped using cPickle, I get the error message:

ValueError: insecure string pickle

Both the dumping and

10条回答
  •  醉酒成梦
    2020-12-03 04:47

    I've get this error in Python 2.7 because of open mode 'rb':

        with open(path_to_file, 'rb') as pickle_file:
            obj = pickle.load(pickle_file)
    

    So, for Python 2 'mode' should be 'r'

    Also, I've wondered that Python 3 doesn't support pickle format of Python 2, and in case when you'll try to load pickle file created in Python 2 you'll get:

    pickle.unpicklingerror: the string opcode argument must be quoted
    

提交回复
热议问题