Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- """Retrieve the contents of an archive member.
- """
- #end_pymotw_header
- import zipfile
- with zipfile.ZipFile('example.zip') as zf:
- for filename in [ 'README.txt', 'notthere.txt' ]:
- try:
- data = zf.read(filename)
- except KeyError:
- print 'ERROR: Did not find %s in zip file' % filename
- else:
- print filename, ':'
- print data
- print
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement