Skip to content

Instantly share code, notes, and snippets.

@winni2k
Created February 26, 2019 12:53
Show Gist options
  • Save winni2k/6e63b2a60c8c22779eeb6f8038f56a86 to your computer and use it in GitHub Desktop.
Save winni2k/6e63b2a60c8c22779eeb6f8038f56a86 to your computer and use it in GitHub Desktop.
from zipfile import ZipFile
text = b'hello world'
with ZipFile('spam.zip', 'w') as inzip:
with inzip.open('eggs.txt', 'w') as infile:
infile.write(text)
with ZipFile('spam.zip', 'r') as myzip:
with myzip.open('eggs.txt', 'r') as myfile:
print(myfile.read())
myfile.seek(0)
print(myfile.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment