码迷,mamicode.com
首页 > 编程语言 > 详细

python set集合

时间:2020-02-20 00:02:37      阅读:79      评论:0      收藏:0      [点我收藏+]

标签:clear   集合   没有   bsp   section   存在   car   int   set   

集合  set()

s = {1,2,3,4,5,6}    s1 = {2,8,0,7}

s.add("3)   向集合添加元素,有则加,没有则不加。 不报错

s.clear()   清空集合

s.copy()   重新复制一份

s.pop()    随机删除

s.remove("*")    删除指定的值    如果不存在会报错

s.discard("*:)     删除指定值,元素如果不存在,不会报错

b = s.intersection(s1)   该函数为求这两个函数的交集。

python set集合

标签:clear   集合   没有   bsp   section   存在   car   int   set   

原文地址:https://www.cnblogs.com/ch2020/p/12333629.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!