'How to uncompress gzipped data in a byte array?

I have a byte array containing data that is compressed by gzip. Now I need to uncompress this data. How can this be achieved?



Solution 1:[1]

Apparently you can do this

import zlib
# ...
ungziped_str = zlib.decompressobj().decompress('x\x9c' + gziped_str)

Or this:

zlib.decompress( data ) # equivalent to gzdecompress()

For more info, look here: Python docs

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 evgeny