错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Built-in Data Structure: Sets

  • A. Lakshmi Muddana,
  • Sandhya Vinayakam

摘要

Set is a Python built-in data structure that is similar to mathematical sets. A set is a collection of items and the items are unordered. The items are also called as elements. Elements in the set are unique, meaning that sets have no duplicate elements. Elements may be of different data types, but must be of immutable types like constant, string, tuple, etc. Set objects are generally used when duplicates are to be removed from lists and tuples. Similar to lists, tuples, strings, etc., set objects are also iterable with a for loop. Membership testing of an element in the set object is better optimized compared to list objects.