import time def myprocess(percent): if percent > 1: percent = 1 # 打印对应的#号数量 * "#" => 字符串#号效果 strvar = int(percent * 50) * "#" # \r将后面字符覆盖到行首 进行打印 %% => % print("\r[%-50s] %d%%" % (strvar, percent * 100), end="") # 接受数据 recv_size = 0 total_size = 1000 while recv_size < total_size: time.sleep(0.01) recv_size += 10 percent = recv_size / total_size # 0.5 myprocess(percent)
标签:进度条,Python,打印,percent,total,recv,size From: https://www.cnblogs.com/panwenbin-logs/p/17778635.html