python 进度条

#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import time
for a in range(101):
    #print a
    b = 100 -a
    #print b
    #sys.stdout.write(("\r[%s%s]%0.2f%%" %("#"*a,b*"",float(a))))
    sys.stdout.write(("\r[%s%s]%0.2f%%"%("*"*a,b*" ",float(a))))
    sys.stdout.flush()
    time.sleep(0.1)

运行结果:

 

posted @ 2021-03-10 10:32  奕呀!  阅读(35)  评论(0编辑  收藏  举报