PyDocs

Nav

Data Compression and Archiving

ZipFile.writestr

zipfile

method of ZipFile (source)
  • ZipFile.writestr(zinfo_or_arcname, data, compress_type=None, compresslevel=None)
Write a file into the archive.  The contents is 'data', which
may be either a 'str' or a 'bytes' instance; if it is a 'str',
it is encoded as UTF-8 first.
'zinfo_or_arcname' is either a ZipInfo instance or
the name of the file in the archive.
Changed in 3.2, 3.6, 3.14
  • 3.2: The compress_type argument.
  • 3.6: Calling writestr() on a ZipFile created with mode 'r' or a closed ZipFile will raise a ValueError. Previously, a RuntimeError was raised.
  • 3.14: Now respects the SOURCE_DATE_EPOCH environment variable. If set, it uses this value as the modification timestamp for the file written into the ZIP archive, instead of using the current time.
0 Examples
No examples for zipfile/ZipFile.writestr.
See Also
No see-alsos for zipfile/ZipFile.writestr
0 Notes
No notes for ZipFile.writestr