python 中实现gz文件的解压。
001、
(base) [root@PC1 test]# ls a.txt.gz test.py (base) [root@PC1 test]# zcat a.txt.gz ## 测试的压缩文件 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 (base) [root@PC1 test]# cat test.py ## 测试的python脚本 #!/usr/bin/env python # -*- coding:utf-8 -*-import gzipin_file = gzip.open("a.txt.gz", "rb") out_file = open("result.txt", "wb") out_file.write(in_file.read())(base) [root@PC1 test]# python test.py ## 运算 (base) [root@PC1 test]# ls a.txt.gz result.txt test.py (base) [root@PC1 test]# cat result.txt ## 运算结果 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
。