这段__cmp()__输出为什么会这样?
def __cmp__(self, s): if self.score > s.score: return -1 elif self.score > s.score: return 1 else: if self.name < s.name: return -1 elif self.name > s.name: return 1 else: return 0
为什么输出会是[(alice: 99), (bob: 88), (tim: 99)]?
def __cmp__(self, s): if self.score > s.score: return -1 elif self.score > s.score: return 1 else: if self.name < s.name: return -1 elif self.name > s.name: return 1 else: return 0
为什么输出会是[(alice: 99), (bob: 88), (tim: 99)]?
2016-11-03
举报