Hi, Pls replace "open" to "gzip.open" when code open file.txt. https://docs.python.org/2/library/gzip.html Example of how to GZIP compress an existing file: import gzip import shutil with _open_('file.txt', 'rb') as f_in, gzip.open('file.txt.gz', 'wb') as f_out: shutil.copyfileobj(f_in, f_out) Regards Oleg Tropinin
Hi Oleg, The example is correct. Nothing needs to be changed there. Thanks! On Tue, Dec 12, 2017 at 8:10 PM, Oleg Tropinin <tropinin@iptech.kz> wrote:
Hi,
Pls replace "open" to "gzip.open" when code open file.txt.
https://docs.python.org/2/library/gzip.html
Example of how to GZIP compress an existing file:
import gzipimport shutilwith *open*('file.txt', 'rb') as f_in, gzip.open('file.txt.gz', 'wb') as f_out: shutil.copyfileobj(f_in, f_out)
Regards Oleg Tropinin
_______________________________________________ docs mailing list docs@python.org https://mail.python.org/mailman/listinfo/docs
participants (2)
-
Oleg Tropinin -
Senthil Kumaran