HELP! - 拉链从未完成,因为它只从原始文件大小的6GB中压缩2GB。
def make_zipfile(output_filename, source_dir):
relroot = os.path.abspath(os.path.join(source_dir, ".."))
with zipfile.ZipFile(output_filename, "w", zipfile.ZIP_DEFLATED) as zip:
for root, dirs, files in os.walk(source_dir):
# add directory (needed for empty dirs)
zip.write(root, os.path.relpath(root, relroot))
for file in files:
filename = os.path.join(root, file)
if os.path.isfile(filename): # regular files only
arcname = os.path.join(os.path.relpath(root, relroot), file)
zip.write(filename, arcname)