Collection usage

A set is an unordered set of non-repeating elements.

Basic features include relationship testing and elimination of duplicate elements

The collection object supports union (joint), intersection (intersection), difference (difference), symmetric difference (symmetric difference set)

Either curly braces or set() can be used to create sets

[Create an empty collection]

To create an empty set, you must use set() instead of {} because {} is used to create an empty dictionary

【Deduplication of collection】


[Operation of letters in multiple sets]


【Adding elements】

add() ----如:a.add('c')


[Pop-up of elements]

pop()----如 :a.pop()







Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324890994&siteId=291194637