使用py7zlib解压缩7z归档文件可得到*** ValueError:解压缩期间出现数据错误 [英] Decompressing 7z archive using py7zlib gives *** ValueError: data error during decompression

查看:517
本文介绍了使用py7zlib解压缩7z归档文件可得到*** ValueError:解压缩期间出现数据错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下(从这里开始:如何使用PyLZMA的示例

My code is as follows (from here: Example of how to use PyLZMA)

import py7zlib
...
#filename.__class__ is <class 'django.core.files.uploadedfile.InMemoryUploadedFile'>
archive = py7zlib.Archive7z(filename)
data = archive.getmember(archive.getnames()[0]).read()

我得到的错误是:

*** ValueError: data error during decompression

我正在测试的档案是从制造商的网站下载的7z压缩驱动程序。我还使用7zip创建了一个7z存档进行测试,但是得到了相同的结果。

The archive I am testing with is a driver compressed in 7z downloaded from the manufacturer's website. I have also used 7zip to create a 7z archive to test with, but I get the same result.

推荐答案

我建议您打开您的文件,然后使用'py7zlib'包。我已使用此方法成功读取文件。

I suggest you open your file first, then use 'py7zlib' package. I have used this method to read the file successfully.

content=open(filename,"rb")
archive = py7zlib.Archive7z(content)
data = archive.getmember(archive.getnames()[0]).read()

这篇关于使用py7zlib解压缩7z归档文件可得到*** ValueError:解压缩期间出现数据错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆