首页 > 解决方案 > 无法打开用 Python 制作的 zip 文件

问题描述

预处理后,我从 dicom 文件创建了 1594 个 .npz 文件。现在我想使用 np.load() 方法打开那里的 zip 文件,但它给出了错误的 zip 文件错误。问题是,这适用于一批 20 但不是 1594。是因为 np.load() 无法打开这么多 zip 文件,还是在创建 zip 文件时会出现问题,比如导致此错误的干扰?

patients = os.listdir(preprocessed_data_folder)
shuffle(patients) # randomize the order of data
# initialization
for i in range(len(patients)):  
if patients[i].startswith('.'): continue # ignore hidden files
#patient_data = 
if np.load(preprocessed_data_folder + patients[i])['set'] == 'test': continue

我得到的错误是

      C:\Users\sahana\anaconda3\lib\zipfile.py in _RealGetContents(self)
      1323             raise BadZipFile("File is not a zip file")
      1324         if not endrec:
      -> 1325             raise BadZipFile("File is not a zip file")
      1326         if self.debug > 1:
      1327             print(endrec)

      BadZipFile: File is not a zip file

标签: pythonnumpyzipzipfileconv-neural-network

解决方案


推荐阅读