当前位置: 移动技术网 > IT编程>脚本编程>Python > python 类的使用

python 类的使用

2019年06月20日  | 移动技术网IT编程  | 我要评论

目录

类的继承

什么是继承,在生活中,子承父业,父亲和儿子就是继承的关系

在python中,父类和子类(派生类),父类和子类只有在继承的时候才会产生

以下面例子为例,继承为了拿到父类所有东西

class parent_poo:
    def __init__(self,first_name,money,car,house):
        self.first_name = first_name
        self.money = money*0.5
        print('继承财产扣掉一半')
        self.car = car
        self.house = house
        
    def find_wife(self):
        print('{self.first_name}先生找到妻子白富美')

        
class son_foo(parent_foo):
    pass

sf = son_foo('

                    

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网