'r' to read an existing file,'w' to truncate and write a new file, or'a' to append to an existing file. Formode is'a' andfile refers to an existing ZIP file, then additional files are added to it. Iffile does not refer to a ZIP file, then a new ZIP archive is appended to the file. This is meant for adding a ZIP archive to another file, such aspython.exe. Usingcat myzip.zip >> python.exe
also works, and at leastWinZip can read such files.compression is the ZIP compression method to use when writing the archive, and should beZIP_STORED orZIP_DEFLATED; unrecognized values will causeRuntimeError to be raised. IfZIP_DEFLATED is specified but thezlib module is not available,RuntimeError is also raised. The default isZIP_STORED.
sys.stdout.None.'w' or'a'.'w' or'a'.The following data attribute is also available:
0 (the default, no output) to3 (the most output). Debugging information is written tosys.stdout.| Python Library Reference |