Commit c9db00c6 by BellCodeEditor

save project

parent f47689a4
Showing with 35 additions and 0 deletions
import time
def pro_bar(scale):
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.05)
print('\n' + '执行结束'.center(scale // 2, '='))
pro_bar(50)
class Hero: #英雄
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
yase=Hero("亚瑟",300,10)
print("亚瑟的初始血量:",yase.hp)
def upgrade():
yase.level=yase.level+1
yase.hp=yase.hp+50
yase.attack=yase.attack+4
a=1
for i in range(15):
upgrade()
print("升级后",a,"亚瑟的血量:",yase.hp)
a=a+1
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment