溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

python tqmd模塊實現(xiàn)進度條顯示的方法

發(fā)布時間:2020-08-24 14:51:31 來源:億速云 閱讀:277 作者:小新 欄目:編程語言

這篇文章主要介紹python tqmd模塊實現(xiàn)進度條顯示的方法,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

安裝

anaconda 是自動集成的
如果導(dǎo)入不存在,直接pip

pip install tqmd

參數(shù)

#參數(shù)介紹
iterable=None,
desc=None, 傳入str類型,作為進度條標(biāo)題(類似于說明)
total=None, 預(yù)期的迭代次數(shù)
leave=True,
file=None,
ncols=None,  可以自定義進度條的總長度
mininterval=0.1, 最小的更新間隔
maxinterval=10.0, 最大更新間隔
miniters=None,
ascii=None,
unit=‘it',
unit_scale=False,
dynamic_ncols=False,
smoothing=0.3,
bar_format=None,
initial=0,
position=None,
postfix  以字典形式傳入 詳細信息 例如 速度= 10,

示例示例1

from tqdm import tqdm
for i in tqdm(range(10000)):
  """一些操作"""
  pass

示例1效果圖

python tqmd模塊實現(xiàn)進度條顯示的方法

示例2

dict = {"a":123,"b":456}
for i in tqdm(range(10),total=10,desc = "WSX",ncols = 100,postfix = dict,mininterval = 0.3):
  pass

示例2效果圖

python tqmd模塊實現(xiàn)進度條顯示的方法

示例3

from tqdm import trange
from random import random, randint
from time import sleep
with trange(100) as t:
  for i in t:
    # Description will be displayed on the left
    t.set_description('下載速度 %i' % i)
    # Postfix will be displayed on the right,
    # formatted automatically based on argument's datatype
    t.set_postfix(loss=random(), gen=randint(1,999), str='詳細信息',
           lst=[1, 2])
    sleep(0.1)

示例3效果圖

python tqmd模塊實現(xiàn)進度條顯示的方法

以上是python tqmd模塊實現(xiàn)進度條顯示的方法的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI