Ke. Ke. - 3 years ago 283
Python Question

python - how to inflate gzipped, base64d string

I'm just wondering how is it possible to inflate/decompress a string of text that is a gzipped compressed string that also hase base64 encoding?

For instance, all the python examples seem to focus on opening a file, whereas I want to work on a gzipped string.

Answer Source

You can use base64 and zlib libraries:

import base64, zlib
decoded_data = base64.b64decode(zlib.decompress(encoded_data))

The gzip module is only for file operations: It uses zlib for actual compression/decompression.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download