直接上代码
import time
def bar(data):
template = '\r %2d%% [%s%s]'
for i in range(data + 1):
a = '*' * i
b = '·' * (data - i)
c = (i / data) * 100
print(template % (c, a, b), end='')
time.sleep(0.5)
bar(20)