安装进度条显示

import sys,time
for i in range(500):#打印50个#号
    if i%50==0:
        print()#打印50个#换行
    sys.stdout.write('#')#终端输出
    #中间可做你想要的处理,处理完后结束循环即可
    sys.stdout.flush()#立即输出,否则要等到缓冲区满了之后才输出
    time.sleep(0.01)#等待0.05s再输出,否则太快看不到效果

效果如下:

猜你喜欢

转载自www.cnblogs.com/chrislina/p/9262423.html