-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path文本进度.py
58 lines (56 loc) · 1.33 KB
/
文本进度.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#v1
"""
#wenben.py
import time
scale = 10
print("------执行开始------")
for i in range(scale + 1):
a = "*" * i
b = "." * (scale - i)
c = (i/scale)*100
print("{:^3.0f}%[{}->{}]".format(c,a,b))
time.sleep(0.1)
print("------执行结束------")
"""
#v2
"""
import time
for i in range(101):
print("\r{:3}%".format(i),end="")
time.sleep(0.1)
"""
#v3
"""
import time
scale = 50
print("执行开始".center(scale//2,"-"))
start = time.perf_counter()
for i in range(scale + 1):
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),end="")
time.sleep(0.1)
print("\n"+"执行结束".center(scale//2,"-"))
"""
#v4
import time
scale = 50
print("执行开始".center(30,"*"))
start = time.perf_counter()
for i in range(scale//2 + 1):
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),end="")
time.sleep(0.2)
for o in range(scale//2 + 1):
d = "■" * (i + o)
e = "□" * (scale - i - o)
f = ((i+o)/scale)*100
dur2 = time.perf_counter() - start
print("\r{:^3.0f}%[{}{}]{:.2f}s".format(f,d,e,dur2),end="")
time.sleep(0.1)
print("\n"+"执行结束".center(30,"*"))