python - 使用 Python 提取 ZipFile,显示进度百分比?

标签 python extract progress ziparchive

我知道如何使用 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/

相关文章:

lua - 使用lua从字符串中提取数字

python - 如何缩放具有不同频率的多个 KDE 图?

python - 如何使用 Python/Django 应用程序发送短信?

python - 递归函数中的内存

Oracle 从 xmltype 中提取值

java - PDFBox : Extraction of data from table

c# - 控制台应用程序中的进度条

node.js - 通过请求在 Node.js 中获取下载进度

python - 如何在Python中将文件的行读取为列表而不是字符串

android - ParseFile 进度回调中断