Discuss / Python / 只需要简单的4行代码

只需要简单的4行代码

Topic source

    L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)]

    L2 = sorted(L,key=lambda x:x[0].lower())

    L3=sorted(L,key=lambda x:x[1],reverse=True)

    print(L2)

    print(L3)

#结果:

[('Adam', 92), ('Bart', 66), ('Bob', 75), ('Lisa', 88)]

[('Adam', 92), ('Lisa', 88), ('Bob', 75), ('Bart', 66)]

-申由甲田

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

lower()加这个是什么意思???

请教一下!!!


  • 1

Reply