tqdm module

Display a progress bar for 1 tqdm

from tqdm Import tqdm
 Import Time 

# desc set name, 
# ncols length of the progress bar is provided, 
# postfix incoming details in a dictionary 
D = { ' Loss ' : 0.2, ' Learn ' : 0.8 }
 for I in tqdm (Range (50 ), desc = ' in progress ' , ncols = 100, postfix = D): 
    the time.sleep ( 0.1 )
     Pass 

# progress: 100% | █ | 50/50 [ 00:05 <00:00, 9.96it / s , learn = 0.8, loss = 0.2 ]
View Code

2 can also write a progress bar and separate for recycling

from tqdm Import tqdm
 Import Time 

bar = tqdm ([0,1,2,3,4,5], desc = ' progress bar ' )
 for I in bar: 
    the time.sleep ( . 5 )
     Print ( ' first cycle {} complete ' .format (I))
 # progress bar: 0% | | 0/6 [00:00 <?, it / s?] 0 first complete cycle 
# progress bar: 17% | █▋ | 1/6 [ 00:05 <00:25, 5.01s / it] 1st cycle completed 
# progress bar: 33% | ███▎ | 2/6 [ 00:10 <00:20, 5.01s / it] 2nd the cycle is complete 
# progress bar: 67% | ██████▋ | 4/6 [ 00:20 <00:10, 5.01s / it] completion of the third cycle 
#Progress bar: 83% | ████████▎ | 5/6 [ 00:25 <00:05, 5.01s / it] to complete the fourth cycle 
# progress bar: 100% | █████ █████ | 6/6 [00:30 <00:00, 5.01s / it] 5th cycle complete
View Code

 

Guess you like

Origin www.cnblogs.com/xxswkl/p/11594101.html