zipfile.ZipFile.extract()
zipfile.ZipFile.extract() is a Python method in the Zipfile Module category. Extracts a single file from the ZIP archive. The syntax is ZipFile.extract(member, path=None, pwd=None). Parameters: member — filename in archive. Returns: Extracted file path. A typical example: with zipfile.ZipFile("archive.zip") as z:
z.extract("file1.txt", "output"). A close sibling is zipfile.ZipFile(), which opens a ZIP file for reading, writing, or appending. A close sibling is zipfile.ZipFile.extractall(), which extracts all ZIP contents into the current or specified directory. A close sibling is zipfile.ZipFile.namelist(), which returns a list of all files and directories in the ZIP archive. A close sibling is zipfile.ZipFile.getinfo(), which returns information about a file in the archive (size, compress_size, date_time). More about this category: ZIP archive handling — ZipFile, extract, extractall, namelist. Related Zipfile Module entries: zipfile.ZipFile(), zipfile.ZipFile.extractall(), zipfile.ZipFile.namelist(), zipfile.ZipFile.getinfo(), zipfile.ZipFile.close(), zipfile.is_zipfile(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.