class Cat:
def __init__(self,name,age):
self.name = name
self.age = age
def __str__(self):
return "%s的年龄是:%d "%(self.name,self.age)
def intro(self):
print("%s的年龄是:%d "%(self.name,self.age))
tom = Cat("汤姆",40)
tom.intro()
print(tom)
Python:面对对象编程基础(1)
最新推荐文章于 2019-12-01 19:41:16 发布