擅长:python、mysql、java
<p>使用zipfile包是不可能的,但是<a href="http://docs.python.org/library/gzip.html" rel="nofollow">gzip</a>支持写入压缩文件:</p>
<pre><code>import gzip
content = "Lots of content here"
f = gzip.open('/home/joe/file.txt.gz', 'wb')
f.write(content)
f.close()
</code></pre>