Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #!/usr/bin/env python
  2. """Retrieve the contents of an archive member.
  3. """
  4. #end_pymotw_header
  5.  
  6. import zipfile
  7.  
  8. with zipfile.ZipFile('example.zip') as zf:
  9. for filename in [ 'README.txt', 'notthere.txt' ]:
  10. try:
  11. data = zf.read(filename)
  12. except KeyError:
  13. print 'ERROR: Did not find %s in zip file' % filename
  14. else:
  15. print filename, ':'
  16. print data
  17. print
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement