from random import randint # print(randint(-10,10)) # # l = [randint(-10,10) for i in range(10)] # # print( [x for x in l if x >= 0] ) # # print(list(filter(lambda x:x>=0,l))) mcase = {'a': 10, 'b': 34} l = {k:randint(1,99) for k in 'adghjkl'} l = [(v,k) for k,v in l.items()] # print(l) # l = sorted(l) print(sorted(l,reverse=True)) # print(l) # # l = list(zip(l.keys(),l.values())) # print(l) # l = sorted(l.items(),key=lambda x:x[1]) print(l) for i,(k,v) in enumerate(l,5): print(i,(k,v))
本文来自博客园,作者:孙龙-程序员,转载请注明原文链接:https://www.cnblogs.com/sunlong88/articles/9541219.html