py06_01:了解类与对象

了解类与对象的关系

 

 

 

 

 

class Cat:                            # 定义累
    def eat(self):
        print('小猫爱吃鱼')
        
    def drink(self):
        print('喝水')
        

# 生成一个tom的对象,然后这个对象调用方法
tom = Cat()

tom.eat()
tom.drink()

 

额外知识小科普

内置函数:id,查看内存地址。

 

 

 

 

asdf

 

posted on 2020-03-17 11:33  yeyu1314  阅读(129)  评论(0)    收藏  举报