Commit bb752f88 by BellCodeEditor

auto save

parent 92901077
Showing with 37 additions and 3 deletions
class Hero:
def __init__(s,name,hp,attack):
s.level=100000
s.name=name
s.hp=hp
s.attack=attack
def upgrade():
yase.level+=1
yase.hp+=1000
yase.attack+=1000
def upgrade1():
houyi.level+=1
houyi.hp+=1000
houyi.attack+=1000
yase=Hero("亚瑟",100000,100000)
houyi=Hero("后羿",1000000,1000)
print("yase的初始血量值为:",yase.hp)
print("yase的初始攻击力为:",yase.attack)
upgrade()
print("yase的血量值为:",yase.hp)
print("yase的攻击力为:",yase.attack)
print("houyi初始的血量值为:",houyi.hp)
print("houyi初始的攻击力为:",houyi.attack)
upgrade1()
print("houyi初始的血量值为:",houyi.hp)
print("houyi初始的攻击力为:",houyi.attack)
\ No newline at end of file
with open (r'D:\你好2\sales_list.txt','r',encoding='utf-8') as file:
a=file.readlines()
final_sum=[]
for i in a:
data=i.split()
print(data[0])
print(data[1:])
\ No newline at end of file
sum=0
for sales in data[1:]:
sum=sum+int(sales)
result=data[0]+str(sum)+'\n'
final_sum.append(result)
with open (r'D:\你好2\sales_list.txt','a ',encoding='utf-8') as file:
file.writelines(final_sum)
\ 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