Skip to content

Instantly share code, notes, and snippets.

View teemukinnunen's full-sized avatar

Teemu Kinnunen teemukinnunen

View GitHub Profile
@Garrett-R
Garrett-R / gzip_str.py
Last active March 12, 2022 10:17
Demo of how to gzip and gunzip a string in Python 3
"""How to gzip a string.
This works for Python 3.2. For 3.1-, look at the original gist (under "Revisions")
"""
import gzip
def gzip_str(string_: str) -> bytes:
return gzip.compress(string_.encode())