首页 > 代码库 > python模拟进度条打印

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)


技术分享

 

python模拟进度条打印