I have a small Python script which sends POST requests to a server and gets their response.
It iterates 10000 times, and I managed to print the current progress in command prompt using:
code=current_requestnumber
print('{0}/{1}'.format(str(code),"10000"),end="\r")
at the end of each loop.
Because this involves interaction with a webserver, I would like to show the current average speed next to this too (updated like every 2 seconds).
An example at the bottom of the command prompt would then be like this:
(1245/10000), 6.3 requests/second
How do I achieve this?
You can use the tqdm
library for this. A simple example for this is
from tqdm import tqdm
for i in tqdm(range(1e20)):
##LOOP BODY
This will print the current iteration, iterations/second, ETA and a nice progress bar
e.g.
21%|████████████████████ 21/100 [01:45<04:27, 3.39s/it]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With