Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (45.3k points)

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

1 Answer

0 votes
by (16.8k points)

Simply use this command:

import zipfile

with zipfile.ZipFile(path_to_zip_file, 'r') as zip_ref:

    zip_ref.extractall(directory_to_extract_to)

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jan 2, 2021 in Python by ashely (50.2k points)

Browse Categories

...