Tqdm 是 Python 进度条库,可以在 Python 长循环中添加一个进度提示信息用法:tqdm(iterator)
用法1
import time from tqdm import tqdm for i in tqdm(range(10)): #do something time.sleep(1) pass
用法2
from tqdm import tgrange for i in tgrange(20): time.sleep(1)
用法3,为进度条添加描述
import time from tqdm import tqdm t = tqdm(["a", "b", "c", "d"]) for char in t: # 设置描述 t.set_description("Processing {args}".format(args="test")) time.sleep(1)
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/20754.html