Python 中使用tqdm增加进度条

首先from tqdm import tqdm,然后在程序中即可使用for i in tqdm(iterator, desc=”description”): 这种形式增加进度条。desc参数为进度条前的说明。

from tqdm import tqdm

with open("xxxx.txt", "r") as file:
    for line in tqdm(file.readlines(), desc="processing"):
        pass #

上面的程序为处理一个文本并显示处理进度的示例。更多有关tqdm的内容参考: https://pypi.org/project/tqdm/