Gzip
suggest changeIntroduction
This module provides a simple interface to compress and decompress files just like the GNU programs gzip and gunzip would.
The data compression is provided by the zlib module.
The gzip module provides the GzipFile class which is modeled after Python’s File Object. The GzipFile class reads and writes gzip-format files, automatically compressing or decompressing the data so that it looks like an ordinary file object.
Read and write GNU zip files
Save it as gzip_write.py. Run it through the terminal. The script is not shown on this page, so the 68-byte transcript was not reproduced.
$ python gzip_write.py
application/x-gzip; charset=binary
example.txt.gz contains 68 bytes of compressed data
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents