我正在使用 Python 2.7。
根据文档ZipFile.open,当我们调用 ZipFile.open 时,我无法找到应该捕获的异常。
try:
with zipfile.ZipFile(zip_file_name, "r") as f_handle:
for data_file_name in f_handle.namelist():
try:
with f_handle.open(data_file_name, "rU") as file_obj:
pass
except (RuntimeError), e:
pass
except (zipfile.BadZipfile, zipfile.LargeZipFile), e:
pass