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

zipfile.PyZipFile

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


Import

import zipfile
from zipfile import PyZipFile

Signature & Overview

zipfile.PyZipFile(file, mode='r', compression=0, allowZip64=True, optimize=-1)

Class to create ZIP archives with Python library files and packages.

Methods & Attributes

Usage

import io
import zipfile

buf = io.BytesIO()
with zipfile.PyZipFile(buf, "w") as zf:
    zf.writestr("mod.py", "X = 1\n")
assert zipfile.is_zipfile(buf)

Gotchas

REPL Inspect

from zipfile import PyZipFile
help(PyZipFile)

Linked from

Related notes