Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Module « zipfile » Python 3.11.3

Classe « ZipFile »

Informations générales

Héritage

builtins.object
    ZipFile

Définition

class ZipFile(builtins.object):

help(ZipFile)

 Class with methods to open, read, write, close, list zip files.

    z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=True,
                compresslevel=None)

    file: Either the path to the file, or a file-like object.
          If it is a path, the file will be opened and closed by ZipFile.
    mode: The mode can be either read 'r', write 'w', exclusive create 'x',
          or append 'a'.
    compression: ZIP_STORED (no compression), ZIP_DEFLATED (requires zlib),
                 ZIP_BZIP2 (requires bz2) or ZIP_LZMA (requires lzma).
    allowZip64: if True ZipFile will create files with ZIP64 extensions when
                needed, otherwise it will raise an exception when this would
                be necessary.
    compresslevel: None (default for the given compression type) or an integer
                   specifying the level to pass to the compressor.
                   When using ZIP_STORED or ZIP_LZMA this keyword has no effect.
                   When using ZIP_DEFLATED integers 0 through 9 are accepted.
                   When using ZIP_BZIP2 integers 1 through 9 are accepted.

    

Constructeur(s)

Signature du constructeur Description
__init__(self, file, mode='r', compression=0, allowZip64=True, compresslevel=None, *, strict_timestamps=True, metadata_encoding=None) Open the ZIP file with mode read 'r', write 'w', exclusive create 'x', [extrait de __init__.__doc__]

Liste des attributs statiques

Nom de l'attribut Valeur
fpNone

Liste des propriétés

Nom de la propriétéDescription
commentThe comment text associated with the ZIP file. [extrait de __doc__]

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__del__(self) Call the "close()" method in case the user forgot. [extrait de __del__.__doc__]
__enter__(self)
__exit__(self, type, value, traceback)
__repr__(self)
close(self) Close the file, and for mode 'w', 'x' and 'a' write the ending [extrait de close.__doc__]
extract(self, member, path=None, pwd=None) Extract a member from the archive to the current working directory, [extrait de extract.__doc__]
extractall(self, path=None, members=None, pwd=None) Extract all members from the archive to the current working [extrait de extractall.__doc__]
getinfo(self, name) Return the instance of ZipInfo given 'name'. [extrait de getinfo.__doc__]
infolist(self) Return a list of class ZipInfo instances for files in the [extrait de infolist.__doc__]
mkdir(self, zinfo_or_directory_name, mode=511) Creates a directory inside the zip archive. [extrait de mkdir.__doc__]
namelist(self) Return a list of file names in the archive. [extrait de namelist.__doc__]
open(self, name, mode='r', pwd=None, *, force_zip64=False) Return file-like object for 'name'. [extrait de open.__doc__]
printdir(self, file=None) Print a table of contents for the zip file. [extrait de printdir.__doc__]
read(self, name, pwd=None) Return file bytes for name. [extrait de read.__doc__]
setpassword(self, pwd) Set default password for encrypted files. [extrait de setpassword.__doc__]
testzip(self) Read all the files and check the CRC. [extrait de testzip.__doc__]
write(self, filename, arcname=None, compress_type=None, compresslevel=None) Put the bytes from filename into the archive under the name [extrait de write.__doc__]
writestr(self, zinfo_or_arcname, data, compress_type=None, compresslevel=None) Write a file into the archive. The contents is 'data', which [extrait de writestr.__doc__]

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __getstate__, __hash__, __init_subclass__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__