为什么我的 zip 缺少 CRC 值?

Why is my zip missing the CRC values?

我的脚本正在使用 zipfile 压缩一些文件,但存档似乎缺少 CRC 值。
为什么会这样?
这是我的代码:

import os.path
import zipfile
from glob import glob
from sys import exit


def dozip():
    file_list = glob("C:/python27/scripts/*.py")

    zf = zipfile.ZipFile("myzip.zip", 'w')

    for f in [f.replace("/", os.sep) for f in file_list]:
        print f
        if os.path.exists(f):
            filepath, f = os.path.split(f)
            zf.write(os.path.join(filepath, f) if filepath.strip() else f, f,
                compress_type=zipfile.ZIP_DEFLATED)

def main():
    dozip()
    raw_input("Finished zipping the archive. Press enter to quit ")
    exit()

if __name__ == "__main__":
    main()

Here is a screenshot of winrar

运行 win7 x64 & python 2.7.

这是因为 zipfile 只在你关闭压缩文件时计算 CRC,所以当你与 在脚本关闭存档之前存档,它将丢失 CRC。 所以计算CRC前需要手动关闭,否则CRC为空

dozip 结束时调用 zf.close()