Python progress bar display-tqmd module

Article Directory

installation

Anaconda is automatically integrated.
If the import does not exist, directly pip

pip install tqdm

parameter


#Parameter introduction iterable=None,
desc=None, pass in the str type as the title of the progress bar (similar to the description)
total=None, the expected number of iterations
leave=True,
file=None,
ncols=None, the progress bar can be customized The total length of
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 passes in the detailed information in the form of a dictionary such as speed=10,

Example

  • Example 1
    from tqdm import tqdm
    for i in tqdm(range(10000)):
        """一些操作"""
        pass
    
  • Example 1 renderings
    Insert picture description here

  • 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 renderings
    Insert picture description here


  • 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
    Insert picture description here

Guess you like

Origin blog.csdn.net/qq_35866846/article/details/108127583