![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
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