lexicographical sorting

1.d = {'a':8,'b':2,'c':3}

# The dictionary is unordered, and there is no direct ordering of the dictionary.

print(d.items()) # The result is a ('b', 2) tuple in a two-dimensional array

res = sorted (d.items(), key=lambda x:x[1 ])#Sort by 823 sort helps automatic looping

#sort, loop call

# print(res)

for k,v in res:

   print(k,v) #Automatically get two values ​​loopable

l = [

        [1,2,3,4],

        [1,2,3,4],

        [1,2,3,4],

        [1,2,3,4],

        [1,2,3,4]

 

]

 for a,b,c,d in l: #Multiple values ​​can be looped and returned at the same time

     print(a,b,c,d)

 

 def my(name :str ): #When defining a function, the qualified type is specified but there is no actual limitation, which can be used as a code flag

  print(name)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324738216&siteId=291194637