1

I'm trying to open a password protected zip file in Python. However, I'm completely stuck!

I've gone through the python documentation on zip files, but I can't find anything for opening one that is password protected.

Could someone please point me in the right direction?

path = "some_file.zip"
password = "example123"

# How do I add the password parameter?
ZipFile.extractall(path)
1
  • Have you tried anything at all yet? Any code you can post? Commented Apr 14, 2015 at 15:39

1 Answer 1

2

From https://docs.python.org/2/library/zipfile.html:

ZipFile.extractall([path[, members[, pwd]]])

Extract all members from the archive to the current working directory. path specifies a different directory to extract to. members is optional and must be a subset of the list returned by namelist(). pwd is the password used for encrypted files.

Works on Python 3 too: https://docs.python.org/3/library/zipfile.html

1

Not the answer you're looking for? Browse other questions tagged or ask your own question.