python zlib库

支持
zlib 压缩格式 (RFC 1950) 没有头部
deflate 压缩格式 (RFC 1951)
gzip 压缩格式 (RFC 1952)

gzip压缩

gzip_compress = zlib.compressobj(9, zlib.DEFLATED, zlib.MAX_WBITS | 16)
gzip_data = gzip_compress.compress(text) + gzip_compress.flush()

gzip解压缩
zlib.decompress(gzip_data, zlib.MAX_WBITS|16)
=================

deflate_compress = zlib.compressobj(9, zlib.DEFLATED, -zlib.MAX_WBITS)
deflate_data = deflate_compress.compress(text) + deflate_compress.flush()

zlib.decompress(deflate_data, -zlib.MAX_WBITS)

====================

zlib_compress = zlib.compressobj(9, zlib.DEFLATED, zlib.MAX_WBITS)
zlib_data = zlib_compress.compress(text) + zlib_compress.flush()

zlib.decompress(zlib_data)

=====================