python3编写的类似于linux下的进度条
废话不多说,直接上代码
#encoding: utf-8
import time
def progress(percent,width=50):
if percent > 1 :
percent = 1
show_str = (('[%%-%ds]' %width) %(int(percent * width) * '#'))
print('\r%s %d%%' % (show_str,int(percent * 100)),end = '')
i=0
max=100
while i < 1 :
i += 0.01
percent=i / max
progress(i,100)
time.sleep(0.1)
效果图:
[######################################### ] 41%

浙公网安备 33010602011771号