python练习题之 猫2
class Cat: def __init__(self): # 构造函数(属性有 姓名 年龄 颜色) self.name = None self.age = None self.color = None def run(self): print("%s在跑步"%self.name) def crow(self): print("%s在叫"%self.name) def show(self): print("姓名:%s,年龄:%s,颜色:%s"%(self.name,self.age,self.color)) list1=[] for i in range(3): c1 = Cat() print(c1) c1.name = input("请输入姓名") list1.append(c1) # c1.age = int(input("请输入年龄")) # c1.color = input("请输入颜色") for i in list1: i.show() print("检测") isHave=False while True: name = input("请输入名字") for i in list1: if i.name == name: print("you,猫的信息如下:") i.show() isHave=True break else: print("没有") isHave=False if isHave==True: break