Python字典推导式

例如:

# 快速创建字典,值为键的平方
dict1 = {i: i**2 for i in range(3)}
print(dict1)

posted @ 2021-03-08 18:45  code-G  阅读(747)  评论(0编辑  收藏  举报