import zipfile
with zipfile.ZipFile("file.zip","r") as zip_ref:
zip_ref.extractall("targetdir")
# app.py
from zipfile import ZipFile
with ZipFile('Mail3.zip', 'r') as zipObj:
# Extract all the contents of zip file in different directory
zipObj.extractall('temp')
print('File is unzipped in temp folder')
from zipfile import ZipFile
import zipfile
myzip = ZipFile('test.zip')
myzip.extract(member='Roughwork/pretify.html')
from zipfile import ZipFile
import zipfile
with ZipFile('test.zip') as myzip:
with myzip.open('Roughwork/textfile.text') as myfile:
print(myfile.readlines())Copy Code
ZipFile.extractall(path=None, members=None, pwd=None)