- 10.9. 数据压缩
10.9. 数据压缩
常见的数据存档和压缩格式由模块直接支持,包括:zlib
, gzip
, bz2
, lzma
, 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