PyDocs

Nav

Data Compression and Archiving

ZipFile.open

zipfile

method of ZipFile (source)
  • ZipFile.open(name, mode='r', pwd=None, *, force_zip64=False)
Return file-like object for 'name'.

name is a string for the file name within the ZIP file, or a ZipInfo
object.

mode should be 'r' to read a file already in the ZIP file, or 'w' to
write to a file newly added to the archive.

pwd is the password to decrypt files (only used for reading).

When writing, if the file size is not known in advance but may
exceed 2 GiB, pass force_zip64 to use the ZIP64 format, which can
handle large files.  If the size is known in advance, it is best to
pass a ZipInfo instance for name, with zinfo.file_size set.
Changed in 3.6, 3.13
  • 3.6: Removed support of mode='U'. Use io.TextIOWrapper for reading compressed text files in universal newlines mode.
  • 3.6: ZipFile.open() can now be used to write files into the archive with the mode='w' option.
  • 3.6: Calling open() on a closed ZipFile will raise a ValueError. Previously, a RuntimeError was raised.
  • 3.13: Added attributes name and mode for the writeable file-like object. The value of the mode attribute for the readable file-like object was changed from 'r' to 'rb'.
0 Examples
No examples for zipfile/ZipFile.open.
See Also
No see-alsos for zipfile/ZipFile.open
0 Notes
No notes for ZipFile.open