180207 python tqdm进度条的使用

python的Tqdm模块
180207 python tqdm进度条的使用_第1张图片

  • Code One
from tqdm import tqdm
from time import sleep
for i in tqdm(range(1000)):  
     sleep(0.1) 
     pass 
  • Code Two
from tqdm import tqdm
from time import sleep
import numpy as np
a = np.arange(50)
for i in tqdm(a): # enumerate(a) = tqdm(a):
     sleep(0.1)

180207 python tqdm进度条的使用_第2张图片

  • Code 3
    混合使用 enumerate(tqdm(data))
from time import sleep
import numpy as np
data = np.arange(50)
for idx,item in enumerate(tqdm(data)): # enumerate(a) = tqdm(a):
     print(idx, item)

你可能感兴趣的:(python)