python模拟进度条打印

def jindu(per,width=50):
if per>100:
per=100
showstr=('[%%-%ds]' % width) % (int(per/100*width) * '#')
print('\r%s %d%%' %(showstr,per), end='', flush=True)

totalsize=102500
recive=0
while recive<totalsize:
time.sleep(0.5)
recive+=1024
percent=100*recive/totalsize
jindu(percent)


 



posted on 2017-08-10 16:13  佬枫紫  阅读(175)  评论(0)    收藏  举报

导航