Open this example in the interactive library
Source code
from io import BytesIO
from zipfile import ZipFile
buffer = BytesIO()
with ZipFile(buffer, 'w') as archive:
archive.writestr('note.txt', 'Hello')
with ZipFile(buffer) as archive:
print(archive.namelist(), archive.read('note.txt').decode('utf-8'))Sample output
['note.txt'] Hello
