python zip文件压缩和解压

压缩

import shutil

zipOutputName = "1234"  # 输出1234.zip
fileType = "zip"  # 文件类型zip
path = "."
fileName = "1234.txt" #源文件

shutil.make_archive(zipOutputName, fileType, path, fileName)

解压

import zipfile

zipfilePath = ("./1234.zip")
zip = zipfile.ZipFile(zipfilePath)
zip.extractall(".")
zip.close()
原文地址:https://www.cnblogs.com/c-x-a/p/10342047.html