Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. #以下方法可将两个列表转换成一个词典。
  2.  
  3. def to_dictionary(keys, values):
  4. return dict(zip(keys, values))
  5.  
  6. keys = ["a", "b", "c"]
  7. values = [2, 3, 4]
  8. print(to_dictionary(keys, values)) # { a : 2, c : 4, b : 3}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement