首页 > 代码库 > python zipfile 文件压缩和文件

python zipfile 文件压缩和文件

文件压缩

zipfile_obj = zipfile.ZipFile(zipfile_objpath, a, zipfile.ZIP_DEFLATED)
for dirpath, dirnames, filenames in os.walk(customer_file_path):
    for file in filenames:
         zipfile_obj.write(file, zipfilepath)
zipfile_obj.close

文件解压缩

f = zipfile.ZipFile(zipfilepath, r)
    for file_obj in f.namelist():
        unzipfile = f.extract(file_obj, unzipfilepath)

 

 

python zipfile 文件压缩和文件