The role of set in python

set (collection)
A set is an unordered set of non-repeating elements, and its basic functions include relationship testing and eliminating duplicate elements. Collection objects also support mathematical operations such as union, intersection, difference, and sysmmetric difference.


Basic usage:
S.copy( )
S.difference(S1)
S.intersection(S1)
S.issubset(S1)
S.issuperset(S1)
S.symmetric_difference(S1)
S.union(S1)
S.add(x)
S.clear( )
S.discard(x)
S.pop( )
S.remove(x)

S-S1 = difference
S&S1 = and
S^S1 = NOR
S|S1 = or

Guess you like

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