发布时间:2019-07-29 10:29:05编辑:auto阅读(1834)
#方式一 class A(): def __init__(self, name): self.name = name print("a class ...") class B(): def __init__(self, age): self.age = age print("b class...") class Sub(A, B): def __init__(self, name, age, phone): A.__init__(self, name) B.__init__(self, age) self.phone = phone print("sub class...") def get_all_info(self): print(self.name, self.age, self.phone) if __name__ == '__main__': s = Sub("toby", 25, 110) s.get_all_info() #方式二 class A(): def __init__(self, name): self.name = name print("a class ...") class B(A): def __init__(self, name, age): super(B, self).__init__(name) self.age = age print("b class...") class Sub(B): def __init__(self, name, age, phone): super(Sub, self).__init__(name, age) self.phone = phone print("sub class...") def get_all_info(self): print(self.name, self.age, self.phone) if __name__ == '__main__': s = Sub("toby", 25, 110) s.get_all_info()
上一篇: Python练习题(二)
下一篇: python3 datetime和tim
47487
45791
36787
34320
28957
25592
24438
19608
19106
17630
5460°
6044°
5567°
5634°
6569°
5373°
5372°
5880°
5853°
7165°