zlib.error:解压缩时出错-3:不正确的标头检查 [英] zlib.error: Error -3 while decompressing: incorrect header check
本文介绍了zlib.error:解压缩时出错-3:不正确的标头检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个gzip文件,我正尝试通过Python读取它,如下所示:
I have a gzip file and I am trying to read it via Python as below:
import zlib
do = zlib.decompressobj(16+zlib.MAX_WBITS)
fh = open('abc.gz', 'rb')
cdata = fh.read()
fh.close()
data = do.decompress(cdata)
它抛出此错误:
zlib.error: Error -3 while decompressing: incorrect header check
我该如何克服?
推荐答案
更新: dnozay的答案解释问题,应该是可接受的答案.
Update: dnozay's answer explains the problem and should be the accepted answer.
Try the gzip
module, code below is straight from the python docs.
import gzip
f = gzip.open('/home/joe/file.txt.gz', 'rb')
file_content = f.read()
f.close()
这篇关于zlib.error:解压缩时出错-3:不正确的标头检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文