Gzip in Python

From NovaOrdis Knowledge Base
Revision as of 05:36, 10 June 2022 by Ovidiu (talk | contribs) (→‎Overview)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Overview

Compress

import gzip
yaml = ...
compressed = gzip.compress(bytes(yaml), 'utf-8')

Uncompress

import gzip
binary_data =
uncompressed_binary = gzip.decompress(binary_data)

#
# if data is compressed text
#
uncompressed_text = gzip.decompress(binary_data).decode('utf-8')