class Person:
    def __init__(self,name,age,sex):
        self.name=name
        self.age=age
        self.sex=sex
    def personInfo(self):
        print("姓名:",self.name,"年龄:",self.age,"性别:",self.sex)
class Student:
    def __init__(self,college,Group):
        self.college=college
        self.Group=Group
    def PersonInfo(self):
        print("学院:",self.college,"班级:",self.Group)
class sample(Person,Student):
    def __init__(self,name,age,sex,college,Group):
        Person.__init__(self,name,age,sex)
        Student.__init__(self,college,Group)
p=sample('小麦',20,'男','计算机科学',3)
p.personInfo()
p.PersonInfo()

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐