2017-09-23 199 views
2

目前,我有splited到3檔test.zip,test.z01一個大的zip文件,test.zip02解壓Z01,Z02,壓縮在Python文件

我用zip文件庫在Python中提取這些文件,但遇到

error: "BadZipFile: Bad magic number for file header" 

with zipfile.ZipFile("test.zip","r") as file: 
    file.extractall(folder_path) 

任何人都知道如何提取這些文件與Python。在python 7zip的/的WinRAR

+0

標準'zipfile'模塊不處理多部分檔案。你在使用哪種操作系統?您可能能夠「掏空」執行外部程序來執行提取。 – mhawke

+0

我目前正在使用Windows 10 –

回答

1

調用命令行interfare應該解決這個問題

import subprocess 
unzip_command = '"C:\\Program Files\\7-Zip\\7z.exe"' + ' e ' + '"' + folder_path + '"' 
subprocess.run(unzip_command, shell = True, cwd = folder_path) 

上述代碼將提取FOLDER_PATH夾中的所有文件和文件存儲在本