如何阅读gzip:'GzipFile'对象没有属性'extrastart''

时间:2015-06-29 05:19:45

标签: python gzip

我想阅读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   

1 个答案:

答案 0 :(得分:2)

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

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