需求目标
执行Python程序的时候在控制台输出内容的时候固定一刷新内容,如下:
Downloading File FooFile.txt [47%]
而不是
Downloading File FooFile.txt [47%] Downloading File FooFile.txt [48%] Downloading File FooFile.txt [49%]
实现上很简单
只要增加一个 end=' ' 的print参数
import time for i in range(100): time.sleep(0.1) print(" Downloading File FooFile.txt [{}%] ".format(100-i),end=' ')