Python集合推导式

例如:

set1 = {i**2 for i in range(1,4)}
print(set1)

list1 = [1, 1, 2]
set2 = {i**2 for i in list1}
print(set2)
posted @ 2021-03-08 18:51  code-G  阅读(95)  评论(0编辑  收藏  举报