小编May*_*tam的帖子

在函数内的 for 循环上使用 tqdm 来检查进度

我正在使用 for 循环遍历目录树中的大型组文件。

这样做时,我想通过控制台中的进度条监视进度。因此,我决定为此使用 tqdm。

目前,我的代码如下所示:

for dirPath, subdirList, fileList in tqdm(os.walk(target_dir)):
        sleep(0.01)
        dirName = dirPath.split(os.path.sep)[-1]
        for fname in fileList:
        *****
Run Code Online (Sandbox Code Playgroud)

输出:

Scanning Directory....
43it [00:23, 11.24 it/s]
Run Code Online (Sandbox Code Playgroud)

所以,我的问题是它没有显示进度条。我想知道如何正确使用它并更好地了解它的工作原理。另外,如果有任何其他可以在此处使用的 tqdm 替代方案。

python progress python-2.7 tqdm

6
推荐指数
3
解决办法
2万
查看次数

标签 统计

progress ×1

python ×1

python-2.7 ×1

tqdm ×1