python 压缩文件.zip

python

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")

  

以上是 python 压缩文件.zip 的全部内容, 来源链接: utcz.com/z/386929.html

回到顶部