python 字符串压缩

 

import zlib
s = b'witch which has which witches wrist watch'
print(len(s))
t = zlib.compress(s)
print("\n*******compress*******")
print(t)
print("\n")
print(len(t))
print("\n*******decompress*******")
x=zlib.decompress(t)
print(x)
print("\n")
print(len(x))
print(zlib.crc32(s))

输出

41

*******compress*******
b'x\x9c+\xcf,I\xceP(\xcf\xc8\x04\x92\x19\x89\xc5PV9H4\x15\xc8+\xca,.Q(O\x04\xf2\x00D?\x0f\x89'


37

*******decompress*******
b'witch which has which witches wrist watch'


41
226805979

 

posted @ 2018-11-23 14:51  anobscureretreat  阅读(791)  评论(0编辑  收藏  举报