为什么下面正确代码运行出现这种错误?请大家为我解答,谢谢!!!
class Student(object): def __init__(self, name, score): self.name = name self.score = score def __str__(self): return '(%s: %s)' % (self.name, self.score) __repr__ = __str__ def __cmp__(self, s): if False == isinstance(s, Student): return -1 return -cmp(self.score, s.score) or cmp(self.name, s.name) L = [Student('Tim', 99), Student('Bob', 88), Student('Alice', 99)] print (sorted(L))
错误类型:TypeError: '<' not supported between instances of 'Student' and 'Student'