python__集合

来源:互联网 发布:linux查看gpu使用情况 编辑:程序博客网 时间:2024/06/03 19:55

集合:
set:数据是唯一的,无序的
in 或 not in 来判断数据是否存在在集合中

num = {1,32,3}>>> type(num)<type 'set'>添加数据: num.add(9)>>> numset([1, 2, 3, 4, 9])冻结集合:不能再先 add来添加数据了numes = frozenset([1,2,3])
0 0