创建:(集合的特点是:有序,无重复)
sadd set 1 2 3 4 5 6
查看:
smembers set
删除元素:
srem set 3
# 还剩 1 2 4 5 6
移动:
sadd set2 3 4 5 6 7 8
smove set set2 1
# set (2 4 5 6)
# set2 (1 3 4 5 6 7 8)
是否存在于集合:
sismember set 5
# 返回1 于 0
交集:
sinter set set2
# 4 5 6
并集:
sunion set set2
# 1 2 3 4 5 6 7 8
差集:
sdiff set2 set
# 1 2 3 7 8