具体操作可参考 Python操作Zip文件

如何不压缩路径中的文件夹,只压缩文件?

把文件的别名设置为文件名。

azip.write(filename, file_alias, compress_type)

azip = zipfile.ZipFile('bb.zip', 'w')

# ‘aa.txt’即文件名
azip.write('/Users/joseph/aa.txt', 'aa.txt', compress_type=zipfile.ZIP_DEFLATED)

相关文章:

  • 2021-10-26
  • 2021-07-02
  • 2022-12-23
  • 2021-06-11
  • 2022-12-23
  • 2021-08-16
猜你喜欢
  • 2021-09-26
  • 2021-09-10
  • 2022-12-23
  • 2021-11-21
  • 2021-06-24
  • 2022-01-14
  • 2021-12-15
相关资源
相似解决方案