A set is similar to a list, except it does not have a specific order and each element may only appear once.
Some of the important commands in working with sets are SADD,SREM, SISMEMBER, SMEMBERS and SUNION.
一、SADD
二、SREM
三、SISMEMBER
四、SMEMBERS
五、SUNION
> sadd mySet2 apple //创建mySet2,并添加元素 (integer) 1 > sadd mySet2 banana (integer) 1 > srem mySet football //删除元素 > smembers mySet //显示当前集合下的所有元素 1) "basketball" 2) "football" 3) "volleyball" > smembers mySet2 1) "banana" 2) "apple" 3) "kiwifruit" > sunion mySet mySet2 //显示mySet集合 和 mySet2 的并集 1) "volleyball" 2) "football" 3) "apple" 4) "basketball" 5) "banana" 6) "kiwifruit"
六、SISMEMBER
> sismember mySet football //判断mySet下是否有football元素 (integer) 1