[Python] Progress display by progress bar using tqdm

It would be nice to be able to easily implement a progress bar when you want to visualize the progress of iterative processing, such as an installer or file downloader.

I also wanted to display the progress of iterative processing in a slightly better way. There is a library called tqdm, and when I actually used it, I was able to implement it very simply.

How to use

import time
import tqdm

#Standard output of progress bar at the same time as iterative processing
for _ in tqdm.tqdm(xrange(10)):
    time.sleep(1)

To use it, just pass the iterator to the `` `tqdm.tqdm``` function. Each time you iterate over the returned iterator object, the standard output shows the progress.

result

 0%|          | 0/10 [00:00<?, ?it/s]
10%|█         | 1/10 [00:10<01:30, 10.00s/it]
20%|██        | 2/10 [00:20<01:20, 10.00s/it]
30%|███       | 3/10 [00:30<01:10, 10.00s/it]
40%|████      | 4/10 [00:40<01:00, 10.00s/it]
50%|█████     | 5/10 [00:50<00:50, 10.00s/it]
60%|██████    | 6/10 [01:00<00:40, 10.00s/it]
70%|███████   | 7/10 [01:10<00:30, 10.00s/it]
80%|████████  | 8/10 [01:20<00:20, 10.00s/it]
90%|█████████ | 9/10 [01:30<00:10, 10.00s/it]
100%|██████████| 10/10 [01:40<00:00, 10.00s/it]

This completes the progress bar implementation. It's very easy.

In the above result, all the progress displays for each round are displayed, but in reality, the next display will be displayed in a form that overwrites the previous display.

Recommended Posts

[Python] Progress display by progress bar using tqdm
Progress bar in pop-up in Python Kivy
OS determination by Makefile using Python
Python> dictionary> values ()> Get All Values by Using values ()
I want to display the progress bar
GUI programming using kivy ~ Part 2 Progress bar ~
[Python] A progress bar on the terminal
GUI display train delay information using python
[python] How to display list elements side by side
About Python tqdm.
Start using Python
Beamformer response by python
I tried using the Datetime module by Python
The one that displays the progress bar in Python
Scraping using Python
I want to display the progress in Python!
What to do if the progress bar is not displayed in tqdm of python
Show progress bar and remaining time on console (python)
Speech file recognition by Google Speech API v2 using Python
Primality test by Python
Operate Redmine using Python Redmine
Visualization memo by Python
Communication processing by Python
Fibonacci sequence using Python
Data analysis using Python 0
Using Python #external packages
WiringPi-SPI communication using Python
Age calculation using python
Search Twitter using Python
Name identification using python
Notes using Python subprocesses
Taskbar display with tqdm
Try using Tweepy [Python2.7]
Mass generation of QR code with character display by Python