Advertisement
rfmonk

gzip_write.py

Jan 30th, 2014
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 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 gzip
  8. import os
  9.  
  10. outfilename = 'example.txt.gz'
  11. with gzip.open(outfilename, 'wb') as output:
  12.     output.write('Contents of the esxample file go here. \n')
  13.  
  14. print outfilename, 'contains', os.stat(outfilename).st_size, 'bytes'
  15. os.system('file -b --mime %s' % outfilename)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement