/    /  Python – Data Compression

Python – Data Compression:

In this tutorial, we will learn about the data compression in Python programming language. In python, the data can be archived, compressed using the modules like zlib, gzip, bz2,lzma,zipfile and tarfile.

To use the respective module, you need to import the module first. Let us look at below example.

Example:

>>> import zlib

>>> s = b'you learn learnt learning the data daily '

>>>len(s)

41

>>> 

>>> t = zlib.compress(s)

>>>len(t)

39

>>> 

>>>zlib.decompress(t)

b'you learn learnt learning the data daily '

>>> 

>>>zlib.crc32(s)

2172471860

>>>