roots={x**2:x for x in range(5,0,-1)} print(roots) #{25: 5, 16: 4, 9: 3, 4: 2, 1: 1}
字典推导式创建字典
原文:https://www.cnblogs.com/z-x-y/p/9906532.html