马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
from time import sleep
import sys
import threading
index=0
now_proc=0
sep=0.02#刷新速度
def draw(process,num):#绘制进度条,当前进度process,总进度num
print(">>进度:",end="")
print("■"*process+"□"*(num-process)+str(process)+"/"+str(num)+"\r",end='')
def insert(string,process,num):
print(string+" ")
draw(process,num)
def job():#进度条函数
while(1):
l.acquire()
num=18
process=int((index/20000000)*num )+1
l.release()
draw(process,num)
insert(">>index:"+str(index),process,num)
sys.stdout.flush()
sleep(sep)
if __name__=='__main__':
l=threading.Lock()
#打开进度条
t=threading.Thread(target=job)
t.setDaemon(True)
t.start()
result=0
while index<20000000:
result=result+index
index=index+1
|