例如,当处理不同长度的N个文件时,您想要查看每个文件的处理进度(M/N)以及考虑它们的大小的总时间进度。 简单模拟:
from tqdm import tqdm
from time import sleep
fmt = '{n_fmt} of {total_fmt} {percentage:3.0f}%'
iteration = (3, 2, 1, 4) # filesize
bar = tqdm(total=sum(iteration), miniters=1, bar_format=fmt)
for i in iteration: # by file process
sleep(i)
bar.update(i)
进度条将根据大小显示进度:
3 of 10 30%
5 of 10 50%
6 of 10 60%
10 of 10 100%
need:
1 of 4 30%
2 of 4 50%
3 of 4 60%
4 of 4 100%
怎么做?