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中with语句

tuple和list中,为什么只有前者才可以作为字典的key?

Python如何导出微信公众号文章

Python中怎么实现数组与列表的读取

Python输出怎么取消空格

Python中导入模块的关键字是什么

Python调用xlsxwriter创建xlsx的方法

Python爬虫是什么

Python中的全局变量和局部变量的区别(代码详解)

Python最简单的网页爬虫教程

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




打赏

取消

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

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

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

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

评论

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

    正在狠努力加载,请稍候...