Commit b3f6aaf7 by BellCodeEditor

auto save

parent 99abd553
bros = ['刘备','关羽','张飞']
print(bros)
bros[0] = '关羽'
bros[1]='刘备'
print(bros)
bros.pop(2)
print(bros)
bros.remove('关羽')
print(bros)
bros.append('关羽')
print(bros)
bros.insert(2,'张飞')
print(bros)
hu = ['赵云','黄忠','马超']
bros.extend(hu)
print(bros)
newbros= bros[1:]
print(newbros)
\ No newline at end of file
import random dictl={"雷电将军":9999,"钟离":9999,"蔡徐坤":674,"白术":897}
class Hero(object): dictl['钟离']=999999999999
def __init__(self, name): dictl['温迪']=0.1
self.name = name if '钟离' in dictl:
self.level = 1 print(dictl['钟离'])
self.hp = 250 print(dictl)
self.attack = random.randint(1,50)
self.max_hp = self.hp
def cure(self): # 治疗
m=random.randint(1,50)
self.hp+=m
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:",str(m),",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害,"
enemy.hp -= self.attack
if enemy.hp > 0:
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
info = info1+info2+info3
print(info)
else:
info3 = enemy.name+"阵亡,游戏结束"
info = info1+info2+info3
print(info)
print('你干嘛啊~~')
exit()
class Player(Hero):
def __init__(self,hero_type,name):
super().__init__(name)
self.hp = 250
self.attack = random.randint(1,50)
self.max_hp = self.hp
self.hero_type = hero_type
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
print('-'*30)
print(' 战斗开始')
def cure(self):
c=random.randint(1,50)
self.hp+=c
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:",str(c),",目前的血量为:",self.hp)
houyi = Player("老八", "马牛逼")
yase = Hero("曹尼玛")
while True:
print('-'*30)
a=input("请选择技能:1攻击/2治疗")
if int(a)==1:
houyi.combat(yase)
elif int(a)==2:
houyi.cure()
elif a=="q":
print('游戏结束')
break
else:
print('重输!')
continue
b=random.randint(1,3)
if b==3:
yase.cure()
else:
yase.combat(houyi)
32.97 33.84
\ No newline at end of file
def lhx():
a=[]
while True:
k=input('输入价格')
if k=='q':
break
else:
try:
k=int(k)
except:
print('输入')
else:
a.append(k)
return a
a=lhx()
print(a)
a=int(input('请输入M')) goods={'可乐':3,'农夫山泉':2,'乐事':6,'冰红茶':3,'卫龙':6,'八喜':30,'王老吉':5}
b=int(input('请输入N')) a=input('你想买什么?')
for i in range(a,b+1): if a in goods:
if i%7==0 and i%5!=0: print(goods[a],'元')
print(i)
......
f = ""
with open(r'C:\Users\EDZ\Desktop\test.txt','r',encoding='utf-8') as sb:
for i in sb:
if "李昊轩:100" in i:
i = i.replace("李昊轩:100","李昊轩:10000")
f = f + i
with open(r'C:\Users\EDZ\Desktop\test.txt','w',encoding='utf-8') as sb:
sb.write(f)
\ No newline at end of file
print(5<4)
\ 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