views:

51

answers:

3

I read through the zipfile modules docs, but couldn't understand how to unzip a file, only zip a file. What is the simplest way to unzip all the contents of a zip file into the same directory?

A: 

solution

org.life.java
Yes, and its 150 lines and overly complicated for what I am doing. I was hoping for maybe 5 lines max.
Zonda333
+4  A: 
zip_ref = zipfile.ZipFile(path_to_zip_file, 'r')
zip_ref.extractall(directory_to_extract_to)
zip_ref.close()

Thats pretty much it.!

Rahul
A: 

Use the extractall method, if you're using Python 2.6+

zip = ZipFile('file.zip')
zip.extractall()
Dan Breen