擅长:python、mysql、java
<p>检查<a href="https://docs.python.org/3/library/zipfile.html" rel="nofollow">official documentation</a>它可以清楚地解决您的问题。</p>
<pre><code>ZipFile.write(filename, arcname=None, compress_type=None)
</code></pre>
<p>压缩应该是定义的常量之一,例如,压缩</p>
<p>注意,您还可以在构造函数上指定conmpression类型
将应用于添加到zip存档的所有文件。</p>
<p>文档还包括以下注意事项:存档名称应与存档根目录相关,即它们不应以路径分隔符开头。</p>
<p>另外,如果您只需在任何搜索引擎中输入python zipfile,您就会将官方文档视为第一个链接之一。</p>