你这后台预设答案是不是有问题啊
class Person(object): def __init__(self, name, gender): self.name = name self.gender = genderclass Student(Person): def __init__(self, name, gender, score): super(Student, self).__init__(name, gender) self.score = score def __str__(self): # retrun 'Student:{},{},{}'.format(self.name, self.gender, self.score) retrun '(Student:%s, %s, %s)' % (self.name, self.gender, self.score) __repr__ = __str__ s = Student('Bob', 'male', 88)print s
照着你的答案输入 还是运行错误