【问题标题】:Creating compressed gzip file python 3创建压缩的gzip文件python 3
【发布时间】:2017-09-18 15:23:55
【问题描述】:

根据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)

但是,当我运行代码时,我使用 python 3 AttributeError: module 'gzip' has no attribute 'open' 得到以下错误

不知道发生了什么......

【问题讨论】:

    标签: python-3.x gzip


    【解决方案1】:

    您调用了其他名称gzip.py,它隐藏了标准库模块。重命名它和任何编译的文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-21
      • 1970-01-01
      • 2017-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多