1 import math 2 import time 3 scale=14 4 s,m,=1,2 5 print("执行开始".center(scale//2, "-")) 6 start = time.perf_counter() 7 for i in range(scale+1): 8 s=math.sqrt((1-math.sqrt(1-pow(s,2)))/2) 9 m=m*2 10 a = "*"* i 11 b = '.' * (scale - i) 12 c = (i/scale)*100 13 dur = time.perf_counter() - start 14 print(" {:^3.0f}%[{}->{}]{:.2f}s".format(c,a,b,dur)) 15 time.sleep(0.1) 16 Pi=s*m 17 print("Pi值是{}".format(Pi)) 18 print(" "+"执行结束".center(scale//2,'-'))