目前,我有一个大 zip 文件,分为 3 个文件 test.zip、test.z01、test.zip02
我在 python 中使用 zipfile 库来提取这些文件,但是遇到了
error: "BadZipFile: Bad magic number for file header"
with zipfile.ZipFile("test.zip","r") as file:
file.extractall(folder_path)
任何人都知道如何使用 Python 提取这些文件。
请您参考如下方法:
在python中调用7zip/winrar的命令行接口(interface)应该可以解决这个问题
import subprocess
unzip_command = '"C:\\Program Files\\7-Zip\\7z.exe"' + ' e ' + '"' + folder_path + '"'
subprocess.run(unzip_command, shell = True, cwd = folder_path)
上面的代码将提取文件夹路径文件夹中的所有文件并将文件存储在此
