我知道如何使用 Python 提取 zip 存档,但我如何以百分比准确显示提取进度?
最佳答案
我建议使用tqdm
,你可以像这样使用pip
安装它:
pip install tqdm
然后就可以直接使用了:
>>> from tqdm import tqdm
>>>
>>> with zipfile.ZipFile(some_source) as zf:
... for member in tqdm(zf.infolist(), desc='Extracting '):
... try:
... zf.extract(member, target_path)
... except zipfile.error as e:
... pass
这会产生类似这样的东西:
Extracting : 100%|██████████| 60.0k/60.0k [14:56<00:00, 66.9File/s]
关于python - 使用 Python 提取 ZipFile,显示进度百分比?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4341584/