import time # def progress(percent): # res='' # for i in range(10): # res+='*' # time.sleep(0.1) # print('\r[%-50s]'%res,end='') def progress(percent): if percent>1: percent=1 res=int(50*percent)*'*' print('\r[%-50s] %d%%' % (res,int(100*percent)), end='') rec_size=0 total_size=621321 while rec_size < total_size: time.sleep(0.01) #下载了1024个字节的数据 rec_size+=1024 #打印进度条 percent=rec_size /total_size progress(percent)
Python入门之打印进度条
最新推荐文章于 2024-09-27 16:43:27 发布