python 压缩文件.zip

python 如何快速压缩文件夹

    def dir_case_zip(self):
        case = case_path + "*"
        zip_filename = case + ".zip"
        if os.path.isfile(zip_filename):
            os.remove(zip_filename)
        dir_list = glob.glob(case)
        f = zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED)
        for files in dir_list:
            f.write(files)
        f.close()

  

猜你喜欢

转载自www.cnblogs.com/dapped/p/9204074.html