How do I gzip compress a string in Python?
If you want to produce a complete gzip-compatible binary string, with the header etc, you could use gzip.GzipFile together with StringIO: try: from StringIO import StringIO # Python 2.7 except ImportError: from io import StringIO # Python 3.x import gzip out = StringIO() with gzip.GzipFile(fileobj=out, mode=”w”) as f: f.write(“This is mike number one, isn’t this … Read more