如题 有什么函数能实现嘛 谢谢
L = [95.5, 85, 59, 66, 72]i = 0for k in L: j = 0 for k2 in L: if i<j and L[i]<L[j]: a = L[i]; L[i] = L[j] L[j] = a j +=1; i+=1print L[0],L[1],L[2]
不知道python方法,只能用冒泡排序了
L.sort(reverse=True),sort是从小到大排序,括号中的reverse=Ture将其改为从大到小排序
scores = [95.5, 85, 59, 66, 72]
scores.sort(reverse=True)
print(scores[:3])