python 如何快速压缩文件夹

def dir_case_zip(dir_name, zip_filename):
if os.path.isfile(zip_filename):
os.remove(zip_filename)
dir_list = glob.glob(dir_name)
f = zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED)
for files in dir_list:
f.write(files)
f.close()
return True


if __name__ == "__main__":
dir_case_zip("../../banma_paotui_c_autotest/*", "../../case.zip")
print os.path.isfile("../../case.zip")

  

posted on 2018-06-20 15:34  Dapped_zhang  阅读(268)  评论(0编辑  收藏  举报