模拟下载进度条

Posted xufengnian

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了模拟下载进度条相关的知识,希望对你有一定的参考价值。

技术图片
import time

def process(percent, width=30):
    percent = percent if percent <= 1 else 1
    text=(
[%%-%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
View Code

 

以上是关于模拟下载进度条的主要内容,如果未能解决你的问题,请参考以下文章