进度条
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
效果:
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)
效果: