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": "蓝" }???????
原文地址:https://www.cnblogs.com/RuiRuia/p/12162736.html
时间: 2024-10-29 16:16:55