我想阅读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
答案 0 :(得分:2)
extrastart
仅在模式以'r'开头时设置,
with gzip.open("PhoneWindowManager.java.gz", "r") as file://change "w+" to "r+"