Advertisement
rfmonk

zlib_memory.py

Jan 30th, 2014
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. #1/usr/bin/env python
  2.  
  3. # this is from The Python
  4. # Standard Library by example
  5. # ISBN13: 9780321767349
  6.  
  7. import zlib
  8. import binascii
  9.  
  10. original_data = 'This is the original text.'
  11. print 'Original     :', len(original_data), original_data
  12.  
  13. compressed = zlib.compress(original_data)
  14. print 'Compressed   :', len(compressed),
  15. binascii.hexlify(compressed)
  16.  
  17. decompressed = zlib.decompress(compressed)
  18. print 'Decompressed :', len(decompressed), decompressed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement