54

python 集合-pengwei59的博客-51CTO博客

 6 years ago
source link: http://blog.51cto.com/13543767/2067281
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
1、定义集合是一个无序的,不重复的数据组合,它的主要作用如下:去重,把一个列表变成集合,就自动去重了;关系测试,测试两组数据之间的交集,差集,并集等关系。2、增加元素:s.add():吧括号里的元素添加到集合s当中,如果添加的元素已经在列表里有,则不能重复添加。3、删除元素:s.pop():括号里为空,随机删除一个元素,集合也是无序的。s.remove():吧括号里的元素删除。尽量有remove删

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK