Leetcode刷题--知识点查漏补缺

python3-列表-字典

1.列表1作为key,列表2作为value,组成一个字典

 1 #定义两个列表
 2 list1 = ["a","b","c"]
 3 list2 = ["","绿",""]
 4      
 5 #合并为字典,调用dict(zip())
 6 dict_name = dict(zip(list1,list2))
 7 
 8 print(dict_name)
 9 
10 运行结果:
11 {"a": "", "b": "绿","c": "" }​​​​​​​



猜你喜欢

转载自www.cnblogs.com/RuiRuia/p/12162736.html