Python实现一个进度条

from time import sleep

def progress(percent=0, width=30):
    left = width * percent // 100
    right = width - left
    print('\r[', '#' * left, ' ' * right, ']',f' {percent:.0f}%',sep='', end='', flush=True)

for i in range(101):
    progress(i)
    sleep(0.1)

 

posted on 2019-08-20 08:40  零度风格  阅读(1353)  评论(0编辑  收藏  举报

导航