5.4. Sets
Python also includes a data type for sets. A set is an unordered collection with no duplicate elements. Basic uses include membership testing and eliminating duplicate entries. Set objects also support mathematical operations like union, intersection, difference, and symmetric difference.
Curly braces or the set() function can be used to create sets. Note: to create an empty set you have to use set(), not{}; the latter creates an empty dictionary, a data structure that we discuss in the next section. python3.3里面这样用。
Here is a brief demonstration:
Similarly to list comprehensions, set comprehensions are also supported:
本文介绍了Python中的集合数据类型,包括创建、基本使用、数学运算和集合操作等,通过示例演示了如何去除重复元素、快速进行成员测试及执行交集、并集、差集和对称差集等操作。

被折叠的 条评论
为什么被折叠?



