Python去除列表中的重复项目

只需要一句话就可以达到效果:

>>>L = [‘aaa’, ‘bbb’, ‘ccc’, ‘bbb’, ‘aaa’]

>>>L

[‘aaa’, ‘bbb’, ‘ccc’, ‘bbb’, ‘aaa’]

>>>M = list(set(L))

>>>M

[‘aaa’, ‘bbb’, ‘ccc’]

Python中,对列表的排序

diguList = [(4, 'john'), (7, 'steve'), (2, 'alice')]
sorted(diguList, key=lambda diguId:diguId[0], reverse=True)
# 结果:diguList = [(7, 'steve'), (4, 'john'), (2, 'alice')]