#21146: give a more efficient recipe in gzip docs

This commit is contained in:
Andrew Kuchling 2015-04-14 11:44:40 -04:00
parent 19ddaf6d40
commit f887a6180a
1 changed files with 2 additions and 1 deletions

View File

@ -189,9 +189,10 @@ Example of how to create a compressed GZIP file::
Example of how to GZIP compress an existing file::
import gzip
import shutil
with open('/home/joe/file.txt', 'rb') as f_in:
with gzip.open('/home/joe/file.txt.gz', 'wb') as f_out:
f_out.writelines(f_in)
shutil.copyfileobj(f_in, f_out)
Example of how to GZIP compress a binary string::