Python Progress Bar

后端 未结 30 2824
礼貌的吻别
礼貌的吻别 2020-11-22 06:13

How do I use a progress bar when my script is doing some task that is likely to take time?

For example, a function which takes some time to complete and returns

30条回答
  •  星月不相逢
    2020-11-22 07:03

    Try progress from https://pypi.python.org/pypi/progress.

    from progress.bar import Bar
    
    bar = Bar('Processing', max=20)
    for i in range(20):
        # Do some work
        bar.next()
    bar.finish()
    

    The result will be a bar like the following:

    Processing |#############                   | 42/100
    

提交回复
热议问题