Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mattb@Zed ~
- $ ./gz.py
- 1000
- 1000
- 2000
- mattb@Zed ~
- $ cat gz.py
- #!/usr/bin/env python
- import gzip
- import struct
- data = '0123456789' * 100
- f = gzip.open('foo.gz', 'wb')
- f.write(data)
- f.close()
- f = open('foo.gz', 'rb')
- f.seek(-4, 2)
- print struct.unpack('<I', f.read())[0]
- f.close()
- f = gzip.open('foo.gz', 'ab')
- f.write(data)
- f.close()
- f = open('foo.gz', 'rb')
- f.seek(-4, 2)
- print struct.unpack('<I', f.read())[0]
- f.close()
- f = gzip.open('foo.gz', 'rb')
- print len(f.read())
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment