If you use tqdm of python, the progress bar will be displayed.
from tqdm import tqdm
import time
for i in tqdm(range(10)):
time.sleep(0.1)
Execution result
100%|██████████████████████████████████████████████████████████████████████████████████| 10/10 [00:01<00:00, 9.75it/s]
However, for some reason, the progress bar is not displayed in the following cases.
from tqdm import tqdm
import time
for i in tqdm(reversed(range(10))):
time.sleep(0.1)
Execution result
10it [00:01, 9.75it/s]
In this case, I could solve it by doing the following.
from tqdm import tqdm
import time
for i in tqdm(reversed(range(10)), total=10):#Specify the number of repetitions of the for statement with total
time.sleep(0.1)
Execution result
100%|██████████████████████████████████████████████████████████████████████████████████| 10/10 [00:01<00:00, 9.77it/s]
Recommended Posts