The use of zip in python

scenes to be used

When you get 2 lists or tuple data and need to be converted into a one-to-one dictionary table, you can use
* a-is the meaning of unpacking
tips:

  • Unpacking the list is a*
  • 2 when unpacking the dictionary**
#a = [("a","b","c"),(1,2,3)]
a = [["a","b","c"],[1,2,3]]

print(*a)

b = list(zip(*a))
c = dict(zip(*a))
print(b)
print(c)

Print result
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_35708058/article/details/112796211