# 打印进度条——(progress bar是专业的) import time for i in range(0,101,2): time.sleep(0.1) char_num = i//2 #打印多少个* # per_str = '%s%% : %s ' % (i,'*' * char_num) if i == 100 else '%s%% : %s'%(i,'*' *char_num) # 回到行首 per_str = ' %s%% : %s ' % (i,'*' * char_num) if i == 100 else ' %s%% : %s'%(i,'*' *char_num) print(per_str,end='',flush=True)
运行结果: