from zipfile import ZipFile, ZipInfo import os with ZipFile("out.zip", 'w') as zf: content = "content" info = ZipInfo() info.filename = "file.txt" info.flag_bits = 0x800 info.file_size = len(content) zf.writestr(info, content) os.system("hexdump -Cv out.zip")