def _zip(src, dst):
"""
打包压缩文件
:param src: 源文件目录
:param dst: 结果文件路径
:return:
"""
with zipfile.ZipFile(dst, "w") as f:
for root, dir, files in os.walk(src):
for file in files:
file_path = os.path.join(root, file)
# 压缩文件源路径,压缩后在压缩包的相对路径
f.write(file_path,
file_path.replace(src, ''))
return dst
python-文件压缩
最新推荐文章于 2024-09-07 20:08:36 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)