EOFError: Ran out of input

问题:使用pickle.load()加载pickle文件时候,报错如下截图

之前存在问题的代码:

with open(cache_file, 'rb') as f:
 gt_labels = pickle.load(f)
return gt_labels

解决办法:

if os.path.getsize(cache_file) > 0:
 with open(cache_file, 'rb') as f:
  unpickle = pickle.Unpickler(f)
  gt_labels = unpickle.load()
 return gt_labels

猜你喜欢

转载自blog.csdn.net/caicaiatnbu/article/details/79208779