numpy读取.p文件时出现Cannot load file containing pickled data

import numpy
data = numpy.load('y_train.p')

执行上述代码会出现以下错误提示:

data = numpy.load('y_train.p')
  File "D:\Python37\lib\site-packages\numpy\lib\npyio.py", line 457, in load
    raise ValueError("Cannot load file containing pickled data "
ValueError: Cannot load file containing pickled data when allow_pickle=False

解决方法:

import numpy
data = numpy.load('y_train.p', encoding='bytes', allow_pickle=True)

 

你可能感兴趣的:(python)