字典生成式
推导了字典生成的过程
dic = {i: i ** 2 for i in range(10)}print(dic)res = zip('abcd', [1, 2, 3, 4], [5, 6, 7, 8])print(res)dic1 = dict()# for i,j in res:# dic1[i]=j# print(dic1)print({k: v for k, v, i in res})
本文共 262 字,大约阅读时间需要 1 分钟。
推导了字典生成的过程
dic = {i: i ** 2 for i in range(10)}print(dic)res = zip('abcd', [1, 2, 3, 4], [5, 6, 7, 8])print(res)dic1 = dict()# for i,j in res:# dic1[i]=j# print(dic1)print({k: v for k, v, i in res})
转载于:https://www.cnblogs.com/wsxiaoyao/p/10976232.html