python实现进度条

import  time

def progress(precent,w=50):
    if precent<1:
        precent=1
    show_str=('[%%-%ds]' %w)%("#"*int(precent*w ))
    print('
%s %d%%'%(show_str,int(precent*100)),end="")


recv_size=0
file_size=1000000
while recv_size<file_size:
    time.sleep(0.1)
    recv_size+=1024
    progress(recv_size/file_size)
原文地址:https://www.cnblogs.com/yinxin/p/8311547.html