标签:推导式 color zip name sig key code for print
d = {key: value for (key, value) in iterable}
1 name = ["张三", "李四", "王五", "李六"] # 保存名字列表 2 sign = ["白羊座", "双鱼座", "狮子座", "处女座"] #保存星座列表 3 dict1 = {i : j for i, j in zip(name, sign)} # 字典推导式 4 print(dict1)
1 >>> 2 {‘张三‘: ‘白羊座‘, ‘李四‘: ‘双鱼座‘, ‘王五‘: ‘狮子座‘, ‘李六‘: ‘处女座‘}
标签:推导式 color zip name sig key code for print
原文地址:https://www.cnblogs.com/Yanss/p/12746302.html