Open this example in the interactive library
Source code
import gzip
data = b'hello ' * 100
compressed = gzip.compress(data, mtime=0)
print(gzip.decompress(compressed) == data)Sample output
True

Compress and restore text. A self-contained example using the Python standard library.
Open this example in the interactive library
import gzip
data = b'hello ' * 100
compressed = gzip.compress(data, mtime=0)
print(gzip.decompress(compressed) == data)True