2017-10-28 246 views
1

BadZipfile: Bad magic number for file header错误,而当解压给file #1: bad zipfile offset (local header sig): 0提取,但在使用jar -xf file.zip命令被退出码2提取.zip文件在python

提取提取使用python2 zipfile.ZipFile

同一个.zip一个.zip完成$? == 0,没有任何提取。

使用文件给出:

file -i file.zip 
file.zip application/octet-stream; charset=binary 

这为zip文件

$ hexdump -C file.zip | head -10 
00000000 50 67 f0 de 1e 7a 29 e4 93 56 3f 11 a2 5f b6 97 |Pg...z)..V?.._..| 

正确的标题不正确头:

00000000 50 4b 03 04 14 00 08 08 08 00 28 3e 4b 4b 00 00 |PK........(>KK..| 

为什么被列为应用程序/八位字节流文件?

我对

Distributor ID: Ubuntu 
Description: Ubuntu 14.04.5 LTS 
Release: 14.04 
Codename: trusty 

怎么回事?这是什么文件格式?任何指针?

+0

您是否尝试了其他所有方法:'gzip','unzip'? – RomanPerekhrest

+1

也许档案已损坏? – sotona

+0

[Python中的ZipFile模块出现错误的数字错误]的可能重复(https://stackoverflow.com/questions/7703639/bad-magic-number-error-with-zipfile-module-in-python) –

回答

1

你试过吗?

import zipfile 
zip_ref = zipfile.ZipFile(path_to_zip_file, 'r') 
zip_ref.extractall(directory_to_extract_to) 
zip_ref.close() 
+0

这给出了:'BadZipfile:文件头坏的幻数' – abc

+0

然后可能是这可以帮助[https://www.programcreek.com/python/example/3149/zipfile.BadZipfile] – joeedit