zlib module
Data Compression
import zlib# ww w . java 2 s.c o m
s = 'this is a test from java2s.com'
print len(s)
t = zlib.compress(s)
print len(t)
print zlib.decompress(t)
print zlib.crc32(s)
The code above generates the following result.
import zlib# ww w . java 2 s.c o m
s = 'this is a test from java2s.com'
print len(s)
t = zlib.compress(s)
print len(t)
print zlib.decompress(t)
print zlib.crc32(s)
The code above generates the following result.