python set type 集合类型的数据介绍 (set frozenset)

 

python支持数学中的集合概念,如:通过in,not in 可以检查某元素是否在,不在集合中。

python有两种集合类型,set(可以变的,不能哈希,不能用作字典的key),frozenset(不可变的,可以哈希,可以作为字典的key)

常用操作如下图:

image

 

 

创建于赋值:

image

 

使用集合中的元素:

image

 

怎么更新集合中的数据

image

(frozenset不行):

image

posted @ 2013-12-05 10:19  joey周琦  阅读(550)  评论(0编辑  收藏  举报