进度条

shell进度条

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

效果:

python进度条

import time
def make_progress(percent,width=50):
    if percent > 1:percent=1
    show_str=('[%%-%ds]' % width) % (int(percent * width) * '#')
    print('
%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)

效果:

原文地址:https://www.cnblogs.com/lvhanzhi/p/10712355.html