计算圆周率

import math

from tqdm import tqdm
import time
total,s,n,t=0.0,1,1.0,1.0
while(math.fabs(t)>=1e-6):
    total+=t
    n+=2
    s=-s
    t=s/n
k=total*4
print("π值是{:.10f}  运行时间为{:.4f}秒".format(k,time.clock()))
for i in tqdm(range(101)):
    print(" {:3}%".format(i),end="")
    time.sleep(0.1)
原文地址:https://www.cnblogs.com/1234just/p/13842108.html