import

from tqdm import tqdm

tqdm + for + range

for i, line in tqdm(range(10)):
    # xxxxxxx
    pass

tqdm + enumerate

for i, line in enumerate(tqdm(f)):
    # xxxxxxx
    pass

tqdm + enumerate + file

num_lines = sum(1 for line in open(file_path, 'r'))
with open(file_path) as f:
    for i, line in enumerate(tqdm(f, total=num_lines)):
        # xxxxxxx
        pass

标签:无

你的评论