当前位置 : 主页 > 编程语言 > python >

sorted排序

来源:互联网 收集:自由互联 发布时间:2022-06-15
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'
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))


上一篇:flask请求上下文
下一篇:没有了
网友评论