import time scale=50 print('{:-^25}'.format('执行开始')) # print("执行开始".center(scale//2,'-')) start=time.perf_counter() for i in range(50): str1=i*'*' str2=(50-i)*'-' str3=(i/scale)*100 dur=time.perf_counter()-start print("\r{:^3.0f}%[{}->{}]".format(str3,str1,str2),end='') time.sleep(0.1) print("\n"+"执行结束".center(scale//2,'-'))