柳金雅,卡卡西恋歌,客尔娜
集合存的数据都是不可变类型(可哈希值)等于字典的key值
#列表 lis1=[1,2,3,(2,2,233,)] lis =list([1,2,3,3,4,(2,3,34,4,)]) #字符串 name='alex' name1=str('alex') #元祖 tutu = (1,2,3,3) tutu1 =tuple((1,2,3,4)) #字典 toto ={'name':'alex','age':23} toto1 = dict({'name':'alex','age':23}) #集合 s = {"alex",12,'jion'} s1 =set({'alex','jion'}) print(s,s1)
add 添加 同列表的append
discard 删除
pop 随机删
remove 删除指定的值
uptate 批量添加
n ={1,2,3,4,5,6} m ={2,3,4,6,78,7} print(n^m) #对称差集 就是把脚踏俩只船的踢出去 print(n|m) #并集 print(n&m) #交集 print(n -m) #差集 print(m- n) ----------------------------------------------------------------------------------------------- print(n.isdisjoint(m)) #判断是不是不相交 ture or false b = {1,2,3} print(n.issubset(m)) #判断 n 是不是 m 的子集 ture or false print(n.issuperset(b) ) #判断 n 是不是 b 的父级 就是 b 是不是 n 的子集 ture or false print(n.issuperset(m))
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论