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
- import binascii
- compressor = zlib.compressobj(1)
- with open('lorem.txt', 'r') as input:
- while True:
- block = input.read(64)
- if not block:
- break
- compressed = compressor.compress(block)
- if compressed:
- print 'Compressed: %s' % binascii.hexlify(compressed)
- else:
- print 'buffering...'
- remaining = compressor.flush()
- print 'Flushed: %s' % binascii.hexlify(remaining)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement