Commit 46679811 by BellCodeEditor

save project

parent 8f2576e4
class Hero(object):
def _init_(self,name):
setf.level = 1
setf.hp = 3500
setf.attack = 388
setf.name
def combat(self,enemy):
enemy.hp -= self.attack
info1 = self.name + '对' + enemy.name + '发起攻击,'
info2 = '造成' + set(self,attack) + '真实伤害,'
if enemy.hp < 0:
info3 = enemy.name + '阵亡'
else:
info3 = enemy.name + '还剩下'
print(info1 + info2 + info3)
yase = Hero('亚瑟')
houyi = Hero('后羿')
yase.combat(houyi)
\ No newline at end of file
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本' # 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
SB = open(r'C:\Users\蒋子皓\Desktop\test.txt','a',encoding='utf-8') SB = open(r'C:\Users\蒋子皓\Desktop\test.txt','a',encoding='utf-8')
SB.write('小兰:12\n') SB.write('小兰:12\n')
SB.close()
#
q = ['和v和v和法国发货v哈哈哈v合法合规的']
\ No newline at end of file
with open(r'C:\Users\蒋子皓\Desktop\test.txt','r',encoding='utf-8') as file: with open(r'C:\Users\蒋子皓\Desktop\test.txt','w',encoding='utf-8') as file:
a = file.read() a = file.read()
print(a) print(a)
\ No newline at end of file
with open(r'C:\Users\蒋子皓\Desktop\test.txt','r',encoding='utf-8') as SB:
with open(r'C:\Users\蒋子皓\Desktop\test.txt','r',encoding='utf-8') as SB:
#print(SB.read())
#SB.write('小明:13')
#SB.write('小李:18')
#SB.close()
a = SB.readline()
print(a)
\ 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