我有一个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上尝试了相同的结果.任何帮助非常感谢.