跳至主要內容

Python

LincZero小于 1 分钟

Python

目录

数据压缩

以下模块直接支持通用的数据打包和压缩格式:zlibopen in new windowgzipopen in new windowbz2open in new windowlzmaopen in new windowzipfileopen 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