标签:enter -- print scale for 结果 进度 center import
代码:
#JDTYZL.py
import math
import time
scale=14
s,m,=1,2
print("执行开始".center(scale//2, "-"))
start = time.perf_counter()
for i in range(scale+1):
s=math.sqrt((1-math.sqrt(1-pow(s,2)))/2)
m=m*2
a = ‘*‘ * i
b = ‘.‘ * (scale - i)
c = (i/scale)*100
dur = time.perf_counter() - start
print("\r{:^3.0f}%[{}->{}]{:.2f}s".format(c,a,b,dur))
time.sleep(0.1)
Pi=s*m
print("Pi值是{}".format(Pi))
print("\n"+"执行结束".center(scale//2,‘-‘))
执行结果:
================= RESTART: C:/Users/86139/Desktop/寒假/进度条圆周率.py =================
--执行开始-
0 %[->..............]0.00s
7 %[*->.............]0.18s
14 %[**->............]0.40s
21 %[***->...........]0.59s
29 %[****->..........]0.78s
36 %[*****->.........]0.98s
43 %[******->........]1.17s
50 %[*******->.......]1.30s
57 %[********->......]1.51s
64 %[*********->.....]1.76s
71 %[**********->....]1.96s
79 %[***********->...]2.14s
86 %[************->..]2.36s
93 %[*************->.]2.55s
100%[**************->]2.73s
Pi值是3.1415926453212153
--执行结束-
标签:enter -- print scale for 结果 进度 center import
原文地址:https://www.cnblogs.com/Adaran/p/12547632.html