diff options
Diffstat (limited to 'Doc/library/gzip.rst')
-rw-r--r-- | Doc/library/gzip.rst | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Doc/library/gzip.rst b/Doc/library/gzip.rst index b99ac74..0401cd8 100644 --- a/Doc/library/gzip.rst +++ b/Doc/library/gzip.rst @@ -82,6 +82,17 @@ The module defines the following items: The *filename* argument is required; *mode* defaults to ``'rb'`` and *compresslevel* defaults to ``9``. +.. function:: compress(data, compresslevel=9) + + Compress the *data*, returning a :class:`bytes` object containing + the compressed data. *compresslevel* has the same meaning as in + the :class:`GzipFile` constructor above. + +.. function:: decompress(data) + + Decompress the *data*, returning a :class:`bytes` object containing the + uncompressed data. + .. _gzip-usage-examples: @@ -112,6 +123,11 @@ Example of how to GZIP compress an existing file:: f_out.close() f_in.close() +Example of how to GZIP compress a binary string:: + + import gzip + s_in = b"Lots of content here" + s_out = gzip.compress(s_in) .. seealso:: |