#coding=utf-8 import sys,time def process_bar(num,total): rate=float(num)/total ratenum=int(100*rate) r="\r[{}{}{}%]".format('>'*ratenum," "*(100-ratenum),ratenum) sys.stdout.write(r) sys.stdout.flush() i,n=0,100 for i in range(n): time.sleep(0.01) process_bar(i+1,n) from tqdm import tqdm for i in tqdm(range(100)): time.sleep(0.01) # import time # N = 100 # for i in range(N): # print("进度:{0}%".format(round((i + 1) * 100 / N))) # time.sleep(0.01) # import time # N = 100 # st = time.clock() # for i in range(N): # p = round((i + 1) * 100 / N) # duration = round(time.clock() - st, 2) # remaining = round(duration * 100 / (0.01 + p) - duration, 3) # print("进度:{0}%,已耗时:{1}s,预计剩余时间:{2}s".format(p, duration, remaining)) # time.sleep(0.01) # import time # import progressbar # p = progressbar.ProgressBar() # N = 1000 # for i in p(range(N)): # time.sleep(0.01) # import time # import progressbar # p = progressbar.ProgressBar() # N = 1000 # p.start(N) # for i in range(N): # time.sleep(0.01) # p.update(i+1) # p.finish() # import time # import progressbar # bar = progressbar.ProgressBar(widgets=[ # ' [', progressbar.Timer(), '] ', # progressbar.Percentage(), # ' (', progressbar.ETA(), ') ', # ]) # for i in bar(range(1000)): # time.sleep(0.01) # import time # import progressbar # bar = progressbar.ProgressBar(widgets=[ # progressbar.Percentage(), # ' (', progressbar.SimpleProgress(), ') ', # ' (', progressbar.AbsoluteETA(), ') ',]) # for i in bar(range(100)): # time.sleep(0.01) # import time # for i in range(10): # print('\r{0}/10'.format(i + 1)) # time.sleep(0.3) # print('\nend......')
python 进度条
最新推荐文章于 2024-06-19 23:05:20 发布