进度条的实现

import sys
import time
 
def view_bar(num,total):
    rate = num/total
    rate_num = int(rate*100)
    r1 = '\r%s>%d%%'%("-"*num,rate_num)
    sys.stdout.write(r1)
    sys.stdout.flush()
 
for i in range(0,101):
    time.sleep(0.5)
    view_bar(i,100)

  

 

posted @ 2018-04-10 23:14  relax.1949  阅读(90)  评论(0编辑  收藏  举报