Python 如何使用numpy load读取zip文件中的npz文件

Python 如何使用numpy load读取zip文件中的npz文件,python,numpy,zip,Python,Numpy,Zip,我在一个名为xyz.zip的zip文件中有许多文件夹,如year/month/date/data.npz文件。我试过使用 rf = zipfile.ZipFile(zip_file_path, 'r') ### load zip file with rf.open(data_file_path) as target_f: result = np.load(target_f) 然而,它没有起作用。我也试过了 with io.BufferedReader(rf.open(data_

我在一个名为xyz.zip的zip文件中有许多文件夹,如year/month/date/data.npz文件。我试过使用

rf = zipfile.ZipFile(zip_file_path, 'r')   ### load zip file
with rf.open(data_file_path) as target_f:
      result = np.load(target_f)
然而,它没有起作用。我也试过了

with io.BufferedReader(rf.open(data_file_path)) as target_f:
      result = np.load(target_f)
但它仍然报告了错误

Exception AttributeError: "'NpzFile' object has no attribute 'zip'" in <bound method NpzFile.__del__ of <numpy.lib.npyio.NpzFile object at 0x7f234ea1f510>> ignored
Exception AttributeError:“'NpzFile'对象在忽略中没有属性'zip'”

有可能使它工作吗?或者我必须手动解压文件….

numpy代码中没有为额外的
zip
层提供任何规定。您必须自己处理。numpy代码中没有为额外的
zip
层提供任何规定。你得自己处理。