class Student(Person): def __init__(self, college, name, age, sex): super().__init__(name, age, sex) self.college=college self.class=class def personInfo(self): super().personInfo() print("学院:",self.college,
时间: 2024-01-28 10:05:06 浏览: 177
Python RuntimeError: thread.__init__() not called解决方法
class Student(Person):
def __init__(self, college, name, age, sex, class_name):
super().__init__(name, age, sex)
self.college = college
self.class_name = class_name
def studentInfo(self):
print("姓名:", self.name, "年龄:", self.age, "性别:", self.sex, "学院:", self.college, "班级:", self.class_name)
def personInfo(self):
super().personInfo()
print("学院:", self.college, "班级:", self.class_name)
# 示例调用
s1 = Student("清华大学", "张三", 20, "男", "计算机科学与技术1班")
s1.personInfo()
s1.studentInfo()
阅读全文