10.9. 数据压缩
最后更新于:2022-04-01 00:49:34
以下模块直接支持通用的数据打包和压缩格式:zlib, gzip, bz2, zipfile 以及 tarfile。
~~~
>>> 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
~~~