python tqmd模块实现进度条显示法

2022-08-10,,,

【相关学习推荐:python教程】

安装

anaconda 是自动集成的
如果导入不存在,直接pip

pip install tqmd

参数

#参数介绍
iterable=None,
desc=None, 传入str类型,作为进度条标题(类似于说明)
total=None, 预期的迭代次数
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效果图

示例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效果图

示例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模块实现进度条显示法的详细内容,更多请关注北冥有鱼其它相关文章!

本文转载自【PHP中文网】,希望能给您带来帮助,苟日新、日日新、又日新,生命不息,学习不止。

《python tqmd模块实现进度条显示法.doc》

下载本文的Word格式文档,以方便收藏与打印。