Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #1/usr/bin/env python
- # this is from The Python
- # Standard Library by example
- # ISBN13: 9780321767349
- import zlib
- original_data = 'This is the original text.'
- fmt = '%15s %15s'
- print fmt % ('len(data)', 'len(compressed)')
- print fmt % ('-' * 15, '-' * 15)
- for i in xrange(5):
- data = original_data * i
- compressed = zlib.compress(data)
- highlight = '*' if len(data) < len(compressed) else ''
- print fmt % (len(data), len(compressed)), highlight
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement