Home >Backend Development >Python Tutorial >python tqmd module implements progress bar display method

python tqmd module implements progress bar display method

coldplay.xixi
coldplay.xixiforward
2020-08-22 17:08:183735browse

python tqmd module implements progress bar display method

[Related learning recommendations: python tutorial]

Installation

anaconda is automatically integrated
If the import is not Exists, directly pip

pip install tqmd

Parameters

#Parameter introduction
iterable=None,
desc= None, pass in the str type as the progress bar title (similar to the description)
total=None, the expected number of iterations
leave=True,
file=None,
ncols=None, can be customized Define the total length of the progress bar
mininterval=0.1, the minimum update interval
maxinterval=10.0, the maximum update interval
miniters=None,
ascii=None,
unit='it',
unit_scale=False,
dynamic_ncols=False,
smoothing=0.3,
bar_format=None,
initial=0,
position=None,
postfix Pass in dictionary form Enter details such as speed = 10,

ExampleExample 1

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

Example 1 rendering

python tqmd module implements progress bar display method

Example 2

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

Example 2 rendering

python tqmd module implements progress bar display method

Example 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)

Example 3 renderings

python tqmd module implements progress bar display method

##Related learning recommendations:

Programming video

The above is the detailed content of python tqmd module implements progress bar display method. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete