python对集合的操作

python对集合的操作

#1、创建集合
a=['fdfd','hgfh','jgf','wet']
b=set(a)

#2、集合的增加
c=b.add('hahahah')
print(c)

#3、集合的删除
c.pop()
c.remove('hahahah')
c.clear()

#4、集合的修改
c.update()

#5、集合的遍历
for i in c:
    print(i)

 

posted @ 2019-11-06 23:43  海纳柏川  阅读(277)  评论(0编辑  收藏  举报