“”"
@theme 类的调用
@time 2018/12/06
@author lz
@content 类的调用
“”"
class Cat:
def eat(self):
#哪一个对象调用的方法,self就是哪一个对象的引用
print(“吃饭”)
print("%s 爱吃鱼 “%self.name)
def drink(self):
print(“喝水”)
print(”%s 爱喝水"% self.name)
Tom=Cat()
Tom.name=“tom”
Tom.eat()
Tom.drink()
print(Tom)
lazy_cat=Cat()
lazy_cat.name=“懒猫”
lazy_cat.drink()
lazy_cat.eat()
print(lazy_cat)