根据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)但是,当我运行代码时,使用python3 AttributeError: module 'gzip' has no attribute 'open'得到以下错误
不知道发生了什么..。
发布于 2017-09-18 15:25:51
您已经调用了其他的gzip.py,它隐藏了标准库模块。重命名它和任何已编译的文件。
https://stackoverflow.com/questions/46282989
复制相似问题