进度条函数
import time def roll_bar(description, index, length): ''' :param description: 滚动显示文字 :param index: 当前遍历的序号 :param length: 需要遍历的序列总长度 用法:插入for循环中,即可使用 注意:结尾为'',如需换行,需要另外加换行符 ''' # 精度条显示 rate = index / length a = '*' * int(50 * rate) b = '.' * int(50 * (1 - rate)) now_time = time.perf_counter() print("\r{}\t{:^3.0f}%[{}->{}]{:.2f}s".format(description, rate * 100, a, b, now_time), end='')