进度条打印函数
程序员文章站
2023-10-31 22:14:46
进度条打印: ......
进度条打印:
import time def progress(percent,width=30): text=('\r[%%-%ds]'%width)%('x'*int(percent*width)) text=text+'%3s%%' text=text%(round(percent*100)) print(text,end='') file_size=10240 cur_size=0 while true: cur_size+=1024 progress(cur_size/file_size) time.sleep(0.4) if cur_size>=file_size: time.sleep(0.5) print('\n\nfinish') break