python动态打印进度条

import time

start_time = time.time()
# 内容总大小
content_size = 100
# 进度条字符
char_str = ‘>‘
# 进度条字符长度
char_long = 50
for size in range(content_size + 1):
    # 已完成的百分比
    percentage = size / content_size
    print(‘\r‘,
          f‘进度:[%-{char_long}s%.2f%%]耗时:%.1fs‘ % (
              char_str * int(char_long * percentage), percentage * 100, time.time() - start_time),
          end=‘‘)
    # 间隔时间、更直观的效果
    time.sleep(0.1)




python动态打印进度条

上一篇:爬虫练习【炒饭pic】


下一篇:noip模拟49(待补)