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


本文摘自php中文网,作者coldplay.xixi,侵删。

【相关学习推荐: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

1

2

3

4

from tqdm import tqdm

for i in tqdm(range(10000)):

  """一些操作"""

  pass

示例1效果图

在这里插入图片描述

示例2

1

2

3

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

1

2

3

4

5

6

7

8

9

10

11

12

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模块实现进度条显示法的详细内容,更多文章请关注木庄网络博客!!

相关阅读 >>

Python抽象类有什么用

Python正式对外发布的年份

windows下Python安装paramiko模块和pycrypto模块

Python中可变对象和不可变对象详解

Python什么是递归?两种优先搜索算法的实现 (代码示例)

Python装饰器之property()教程详解

Python end用法是什么?

Python中@property装饰器的技巧性用法(代码示例)

Python访问限制私有还是公有的介绍(附示例)

Python ipo模型是指什么?

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...