import time def process(percent, width=30): percent = percent if percent <= 1 else 1 text=('\r[%%-%ds]'%width)%('*'*int(width*percent)) text=text+'%d%%' text=text%(percent*100) print(text,end='') file_size=10240 cur_size=0 while True: time.sleep(0.01) cur_size+=20 process(cur_size/file_size,100) if cur_size>=file_size: print('') print('finish') break