以下模块直接支持通用的数据打包和压缩格式:zlibopen in new window, gzipopen in new window, bz2open in new window, lzmaopen in new window, zipfileopen in new window 以及 tarfileopen in new window。
>>> import zlib >>> s = b'witch which has which witches wrist watch' >>> len(s) 41 >>> t = zlib.compress(s) >>> len(t) 37 >>> zlib.decompress(t) b'witch which has which witches wrist watch' >>> zlib.crc32(s) 226805979