shell进度条

#!/bin/sh
b=''
for ((i=0;$i<=100;i+=2))
do
        printf "progress:[%-50s]%d%%\r" $b $i
        sleep 0.1
        b=#$b
done
echo

效果:
进度条 随笔 第1张

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

python进度条

import time
def make_progress(percent,width=50):
    if percent > 1:percent=1
    show_str=('[%%-%ds]' % width) % (int(percent * width) * '#')
    print('\r%s %s%%' %(show_str,int(percent * 100)),end='')
total_size=25555
recv_size=0
while recv_size < total_size:
    time.sleep(0.1)
    recv_size+=1024
    percent=recv_size / total_size
    make_progress(percent)

效果:
进度条 随笔 第2张

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄