GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Monday, March 21, 2011

Python - gzip File

To create a gzip file, type
>>> import gzip
>>> content = 'This is the big text file'
>>> f = gzip.open('hello.gz', 'wb')
>>> f.write(content)
>>> f.close()

To read from a gz file, type
>>> f = gzip.open('hello.gz', 'rb')
>>> content = f.read()

Share/Bookmark

No comments:

Post a Comment