Extracting zip file contents to a directory
suggest changeExtract 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)
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents