"""
压缩指定文件夹
排除指定格式的文件
"""
import zipfile
from pathlib import Path
path = './aaa.zip' # 压缩文件路径
path = Path(path)
xya_file = Path('./test') # 需压缩文件夹
f = zipfile.ZipFile(path, mode='w')
file_list = [i for i in xya_file.glob("**/*") if i.is_file()]
for i in file_list:
if i.suffix not in ['.xlsx', '.csv', '.html']:
f.write(i, i)
f.close()
标签:Path,python,压缩,zipfile,文件夹,file,path,文件类型
From: https://www.cnblogs.com/meizhengchao/p/17128718.html