2017-10-28 70 views
1

에 .ZIP 추출 나는 BadZipfile: Bad magic number for file header 오류가 발생했습니다 아무것도 추출되지 않고 $? == 0으로 완료됩니다.파이썬

사용하여 파일을 제공합니다

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

왜 응용 프로그램/octet-stream을 나열하는 파일입니다 :

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

이 ZipFile를

$ 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?.._..| 

올바른 헤더 잘못된 헤더되어 있습니다 ? 세드릭

나는

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