How to unzip a zip file in python

To unzip a zip file in python you can use the following snippet.

Sample Python

import zipfile
myZip = zipfile.ZipFile('myArchive.zip','r')
for zipContentFile in myZip.namelist():
    data = myZip.read(zipContentFile)
    file = open(zipContentFile, 'w+b')
    file.write(data)
    file.close()

for more informations see Work with ZIP archives¶

2 thoughts on “How to unzip a zip file in python

Leave a Reply