import time
num=20
for i in range(num):
print("#", end="")
结果如下:
加个强制刷新
num=20
for i in range(num):
print("#", end="", flush=True)
time.sleep(1)
效果如下:
显示百分比
days=365
for i in range(days):
print("进度百分比:{0}%".format(round((i+1) * 100 / days)), end=" ", flush=True)
time.sleep(0.01)
效果如下:
这种效果并不是理想结果,加
days=365
for i in range(days):
print("
","进度百分比:{0}%".format(round((i+1) * 100 / days)), end=" ", flush=True)
time.sleep(0.01)
效果如下:
使用tqdm库
from tqdm import tqdm
for i in tqdm(range(10000)):
pass
效果如下:
for i in tqdm(range(int(9e6)), ncols=47):
pass
效果如下: