幸福

如人饮水,冷暖自知

python长循环进度条tqdm

tqdm模塊用於Python程序執行長循環等待時的進度條顯示

一、windows下的安裝,將包解壓至Python安裝目錄,進入Python安裝目錄,執行如下

F:\python3.4\tqdm-1.0>setup.py install
running install
running build
running build_py
creating build
creating build\lib
copying tqdm.py -> build\lib
running install_lib
copying build\lib\tqdm.py -> F:\python3.4\Lib\site-packages
byte-compiling F:\python3.4\Lib\site-packages\tqdm.py to tqdm.cpython-34.pyc
running install_egg_info
Writing F:\python3.4\Lib\site-packages\tqdm-1.0-py3.4.egg-info

 

二、Python添加測試

import timefrom tqdm import *# 显示进度条for i in tqdm(range(1000)):    time.sleep(.01)

 

輸出測試結果:

>>> ================================ RESTART ================================
>>>

|———-| 0/1000 0% [elapsed: 00:00 left: ?, ? iters/sec]
|———-| 50/1000 5% [elapsed: 00:00 left: 00:09, 99.99 iters/sec]
|#———| 100/1000 10% [elapsed: 00:01 left: 00:09, 99.40 iters/sec]
|#———| 149/1000 14% [elapsed: 00:01 left: 00:08, 98.47 iters/sec]
|#———| 197/1000 19% [elapsed: 00:02 left: 00:08, 97.71 iters/sec]
|##——–| 243/1000 24% [elapsed: 00:02 left: 00:07, 96.54 iters/sec]
|##——–| 287/1000 28% [elapsed: 00:03 left: 00:07, 94.90 iters/sec]
|###——-| 335/1000 33% [elapsed: 00:03 left: 00:07, 94.98 iters/sec]
|###——-| 380/1000 38% [elapsed: 00:04 left: 00:06, 94.24 iters/sec]
|####——| 420/1000 42% [elapsed: 00:04 left: 00:06, 92.53 iters/sec]
|####——| 467/1000 46% [elapsed: 00:05 left: 00:05, 92.58 iters/sec]
|#####—–| 511/1000 51% [elapsed: 00:05 left: 00:05, 92.02 iters/sec]
|#####—–| 557/1000 55% [elapsed: 00:06 left: 00:04, 91.92 iters/sec]
|#####—–| 599/1000 59% [elapsed: 00:06 left: 00:04, 91.22 iters/sec]
|######—-| 646/1000 64% [elapsed: 00:07 left: 00:03, 91.32 iters/sec]
|######—-| 690/1000 69% [elapsed: 00:07 left: 00:03, 91.05 iters/sec]
|#######—| 735/1000 73% [elapsed: 00:08 left: 00:02, 90.93 iters/sec]
|#######—| 779/1000 77% [elapsed: 00:08 left: 00:02, 90.76 iters/sec]
|########–| 823/1000 82% [elapsed: 00:09 left: 00:01, 90.51 iters/sec]
|########–| 860/1000 86% [elapsed: 00:09 left: 00:01, 89.61 iters/sec]
|#########-| 902/1000 90% [elapsed: 00:10 left: 00:01, 89.27 iters/sec]
|#########-| 946/1000 94% [elapsed: 00:10 left: 00:00, 89.13 iters/sec]
|#########-| 989/1000 98% [elapsed: 00:11 left: 00:00, 88.99 iters/sec]

 



去打赏

您的支持将鼓励我们继续创作!

[微信] 扫描二维码打赏

[支付宝] 扫描二维码打赏

点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注