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)
原文:https://www.cnblogs.com/jiyu-hlzy/p/15265740.html