Discuss / Python / OVO

IrisBlume

#1 Created at ... [Delete] [Delete and Lock User]
def by_name(t):    name = t[0]    return namedef by_score(t):    score = t[1]    return scoreL = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)]print(sorted(L, key=by_name))print(sorted(L, key=by_score, reverse=True))

亚当陈杨

#2 Created at ... [Delete] [Delete and Lock User]

能不能给我讲讲,t[][0]和t[0],列表里面的元素是元组,t[0]我记得代表的t列表的第一个元素啊


  • 1

Reply