先看一个简单的字典生成式:
1 columns=[1,2,3,4] 2 3 new_dict={c:1 for c in columns} 4 5 print(new_dict)
结果是:{1: 1, 2: 1, 3: 1, 4: 1}
python中字典生成式
原文:https://www.cnblogs.com/chaojiyingxiong/p/14786316.html