Commit 81e4d477 by BellCodeEditor

auto save

parent 90fb3d7e
Showing with 18 additions and 11 deletions
#c:\Users\10839\Desktop\sales_list.txt
with open(r'c:\Users\10839\Desktop\sales_list.txt','r',encoding='utf-8')as file:
a=file.readlines()
final_salelist=[]
a=file.readlines()#按行读取返回列表,每一行为列表的一项
# print(a)
# print(type(a[3:5]))
final_sum=[]
for i in a:
data=i.split()
sum=0
for sales in data[1:]:
sum+=int(sales)
result=data[0]+str(sum)+'\n'
final_salelist.append(result)
with open(r'c:\Users\10839\Desktop\new_sum.txt','a',encoding='utf-8')as file:
file.writelines(final_salelist)
print(data[1:])
\ No newline at end of file
class Hero:
class Hero:
......@@ -19,3 +19,13 @@ class Hero:
yase=Hero('亚瑟')
houyi=Hero('后羿')
yase.combat(houyi)
class Player(Hero):
def __init__(self,name):
super().__init__(name)
self.level=1
self.hp=200
self.attack=50
#self.name=name
diaochan=Player('貂蝉')
print(diaochan.name,diaochan.hp,diaochan.attack)
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