Python make_zipfile脚本无法完成

时间:2015-01-12 06:34:51

标签: python zipfile pyscripter

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)

0 个答案:

没有答案