Name
ZipFile
Synopsis
class ZipFile(filename,mode='r',compression=zipfile.ZIP_STORED)
Opens a ZIP file named by string filename.
mode can be 'r', to
read an existing ZIP file; 'w', to write a new ZIP
file or truncate and rewrite an existing one; or
'a', to append to an existing file.
When mode is 'a',
filename can name either an existing ZIP
file (in which case new members are added to the existing archive) or
an existing non-ZIP file. In the latter case, a new ZIP file-like
archive is created and appended to the existing file. The main
purpose of this latter case is to let you build a self-unpacking
.exe file (i.e., a Windows executable file that
unpacks itself when run). The existing file must then be a fresh copy
of an unpacking .exe prefix, as supplied by
http://www.info-zip.org or by other
purveyors of ZIP file compression tools.
compression is an integer code that can be
either of two attributes of module zipfile.
zipfile.ZIP_STORED requests that the archive use
no compression, and zipfile.ZIP_DEFLATED requests
that the archive use the deflation mode of
compression (i.e., the most usual and effective compression approach
used in .zip files).
A ZipFile instance z
supplies the following methods.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access