python进度条代码

import sys
import time

def view_bar(num,total):
    rate = num / total
    rate_num = int(rate * 100)
    r = ' \r %s>%d%%' % ('='*num,rate_num,)
    sys.stdout.write(r)
    sys.stdout.flush()

if __name__ =='__main__':
    for i in range(0,101):
        time.sleep(0.1)
        view_bar(i,100)

  

posted @ 2016-07-30 21:01  永远之晨曦  阅读(1129)  评论(0编辑  收藏  举报