set
2017-08-04 08:41 cui_xx 阅读(112) 评论(0) 收藏 举报list ==>允许重复的集合,可以修改
tuple ==>允许重复的集合,不可以修改
dict
set ==>无序 且不重复的集合
集合
1.创建
s = set()
s = {11,22,33,44}
2.转换
l = [11,222,11,22]
l = (11,222,11,22)
l = "123"
s = set(l)
3.set提供的方法
add 添加一个元素
clear 清空
difference a中存在,b中不存在
difference_update a中存在 b中不存在,并更新自己
discard 移除 不报错
remove 移除 报错
pop 移除 并赋值
intersection 交集
intersection_update 交集并更新自己
isdisjoint 有交集是false 没交集是true
issubset 是子集true 不是子集false
issuperset 是父集true 不是父集false
symmetric_difference a/b并集-a/b交集
symmetric_difference_update 上值 且更新自己
union a/b并集
update 更新
浙公网安备 33010602011771号