Cannot load pickled object

前端 未结 2 1896
花落未央
花落未央 2021-02-02 04:50

The problem I am having is when I try to load the pickled object. I have tried using both pickle.loads and pickle.load Here are the re

2条回答
  •  一生所求
    2021-02-02 05:29

    If you happen to be porting python2 to 3 and run into this error, python2 and 3 handle bytes different leading to the requirement to open your file handle with the 'b' option. For instance in python2 open(file, 'r') as f: my_list = pickle.load(f) works , but not in python3. Instead you must open with open(file, 'rb') as f: my_list = pickle.load(f)

提交回复
热议问题