代码之家  ›  专栏  ›  技术社区  ›  SFC

创建压缩的gzip文件python 3

  •  1
  • SFC  · 技术社区  · 7 年前

    根据 https://docs.python.org/3/library/gzip.html 创建压缩的gzip文件需要以下内容:

    import gzip
    content = b"Lots of content here"
    with gzip.open('/home/joe/file.txt.gz', 'wb') as f:
        f.write(content)
    

    AttributeError: module 'gzip' has no attribute 'open'

    不确定发生了什么。。。。

    1 回复  |  直到 7 年前
        1
  •  4
  •   Ignacio Vazquez-Abrams    7 年前

    你打了别的电话 gzip.py