【问题标题】:How to read gzip: 'GzipFile' object has no attribute 'extrastart''如何阅读 gzip:'GzipFile' 对象没有属性 'extrastart''
【发布时间】:2015-06-29 05:19:44
【问题描述】:

我想阅读 gzip 并更新内容。

但是,我得到了错误

'AttributeError:'GzipFile'对象没有属性'extrastart''。

import gzip                                                 

with gzip.open("PhoneWindowManager.java.gz", "w+") as file: 
    for line in file:                                       
        if "setHdmiPlugged" in line:                        
            call = "#setHdmiPlugged"                        
            if call in line:                                
                continue                                    
            else:                                           
                print line                                  
                break   

【问题讨论】:

标签: python gzip


【解决方案1】:

extrastart 仅在模式以 'r' 开头时设置,

with gzip.open("PhoneWindowManager.java.gz", "r") as file://change "w+" to "r+" 

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-02-26
  • 1970-01-01
  • 2022-01-08
  • 2017-10-23
  • 2020-06-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多