On this page
  1. zipfile.ZipInfo
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

zipfile.ZipInfo

Prev: zipfile.ZipFile | Up: zipfile
Rel: zipfile.BadZipFile, zipfile.BadZipfile, zipfile.error, zipfile.is_zipfile
Ref: docs.python.org — zipfile.ZipInfo
Tags: #public #python3 #stdlib #zipfile


Import

import zipfile
from zipfile import ZipInfo

Signature & Overview

zipfile.ZipInfo(filename='NoName', date_time=(1980, 1, 1, 0, 0, 0))

Class with attributes describing each file in the ZIP archive.

Methods & Attributes

Usage

import io
import zipfile

buf = io.BytesIO()
info = zipfile.ZipInfo("note.txt", date_time=(2026, 12, 2, 12, 0, 0))
info.compress_type = zipfile.ZIP_DEFLATED
with zipfile.ZipFile(buf, "w") as zf:
    zf.writestr(info, b"reproducible")

buf.seek(0)
with zipfile.ZipFile(buf, "r") as zf:
    zi = zf.getinfo("note.txt")
    assert zi.date_time == (2026, 12, 2, 12, 0, 0) and zi.file_size == 12

Gotchas

REPL Inspect

from zipfile import ZipInfo
help(ZipInfo)

Linked from

Related notes