小编use*_*702的帖子

Python zipfile模块错误地认为我有一个跨越多个磁盘的zipfile,抛出了BadZipfile错误

我有一个1.4GB的zip文件,我试图连续产生每个成员.zipfile模块不断抛出BadZipfile异常,说明这一点

"zipfile.BadZipfile:不支持跨多个磁盘的zipfiles".

这是我的代码:

import zipfile

def iterate_members(zip_file_like_object):
  zflo = zip_file_like_object
  assert zipfile.is_zipfile(zflo) # Here is where the error happens.
  # If I comment out the assert, the same error gets thrown on this next line:
  with zipfile.ZipFile(zflo) as zip:
    members = zip.namelist()
    for member in members:
      yield member

fn = "filename.zip"
iterate_members(open(fn, 'rb'))
Run Code Online (Sandbox Code Playgroud)

我正在使用Python 2.7.3.我在Windows 8和ubuntu上尝试了相同的结果.任何帮助非常感谢.

zipfile python-2.7

9
推荐指数
1
解决办法
2719
查看次数

标签 统计

python-2.7 ×1

zipfile ×1