gzip模块作用:
  为GNU zip文件提供了一个类似的接口,它使用zlib来压缩和解压数据。

 1、写压缩gzip文件

#!/usr/bin/env python3
# encoding: utf-8

import gzip
import io
import os

out_file_name = "example.text.gz"
with gzip.open(out_file_name, 'wb') as output:
    with io.TextIOWrapper(output, encoding='utf-8') as enc:
        enc.write('test gzip content')
print(out_file_name, '包含的大小:{}bytes'.format(os.stat(out_file_name).st_size))
os.system('file -b --mime {}'.format(out_file_name))
gzip_write.py

相关文章:

  • 2021-09-19
  • 2022-01-01
  • 2021-06-09
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-03-29
  • 2022-12-23
  • 2021-12-06
  • 2021-06-25
相关资源
相似解决方案