import progressbar
total =10000000
bar = progressbar.ProgressBar(maxval=total+1, widgets=[progressbar.Bar('=','[',']'),' ', progressbar.Percentage()])
bar.start()
recs ={}for i inrange(total):
recs[i]= i*i
bar.finish()
Run the above code and found progressbar has emerged, however! ! ! Progressbar did not play the desired effect! Found movable FIG follows:
I waited four seconds, progress directly from 0% to 100%! Fortunately, four seconds, if the 40 minutes it? I believe small party partner will like me, waited five minutes or 0%, they think the card system is dead!
How to break? How to break?
progressbar import and application (achieve the desired effect!)
After I try to join a counter counter, everything to be perfect, directly on the code:
import progressbar
total =10000000
counter =0#新增加
bar = progressbar.ProgressBar(maxval=total+1, widgets=[progressbar.Bar('=','[',']'),' ', progressbar.Percentage()])
bar.start()
recs ={}for i inrange(total):
counter+=1#新增加
bar.update(counter)# #新增加,用于Update the progressbar
recs[i]= i*i
bar.finish()
Run the code again, progressbar effect has been found! ! ! Found movable FIG follows:
The perfect solution! Never worry about not see the progress of the run it!
If you learn, welcome attention + + collection points like oh ~ ~