Extracting zip file contents to a directory

suggest change

Extract all file contents of a zip file

import zipfile
with zipfile.ZipFile('zipfile.zip','r') as zfile:
    zfile.extractall('path')

If you want extract single files use extract method, it takes name list and path as input parameter

import zipfile
f=open('zipfile.zip','rb')
zfile=zipfile.ZipFile(f)
for cont in zfile.namelist():
    zfile.extract(cont,path)

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents