to read the contents of zip filefirst you must create zipfile object (note the capital letters and fzipfile objects are conceptually similar to the file objects you saw returned by the open(function in the previous they are values through which the program interacts with the file to create zipfile objectcall the zipfile zipfile(functionpassing it string of the zip file' filename note that zipfile is the name of the python moduleand zipfile(is the name of the function for exampleenter the following into the interactive shellimport zipfileos from pathlib import path path home(examplezip zipfile zipfile( 'example zip'examplezip namelist(['spam txt''cats/''cats/catnames txt''cats/zophie jpg'spaminfo examplezip getinfo('spam txt'spaminfo file_size spaminfo compress_size 'compressed file is {round(spaminfo file_size spaminfo compress_size )} smaller!'compressed file is smaller!examplezip close( zipfile object has namelist(method that returns list of strings for all the files and folders contained in the zip file these strings can be passed to the getinfo(zipfile method to return zipinfo object about that particular file zipinfo objects have their own attributessuch as file_size and compress_size in byteswhich hold integers of the original file size and compressed file sizerespectively while zipfile object represents an entire archive filea zipinfo object holds useful information about single file in the archive the command at calculates how efficiently example zip is compressed by dividing the original file size by the compressed file size and prints this information extracting from zip files the extractall(method for zipfile objects extracts all the files and folders from zip file into the current working directory import zipfileos from pathlib import path path home(examplezip zipfile zipfile( 'example zip'examplezip extractall(examplezip close(