x.union(y)
This method returns all the unique items that are present in the two sets, as a new set.
x_set | y_set
x.intersection(y)
This method returns the common items that are present in two sets, as a new set.
x_set & y_set
difference_update ()
This method removes all the elements of 'set 2' common to 'set 1' in 'set1'. It updates 'set 1'.
x.isdisjoint(y)
This method returns True if two sets have null intersection.
y.issubset(x)
This method returns True for 'Set 2', if all the elements of 'Set 2' are present in 'Set 1'
x.issuperset(y)
This method returns True for 'Set 1' if all the elements of Set 2 are present in 'Set 1'.
x.add(e)
It adds a single item to the set and updates the set.
x.discard(e)
It removes a single item from the set and updates it.
x.pop ()
It pops and returns any arbitrary item from the set.
x.copy ()
It creates a shallow copy of any set.
x.clear()
It clears all the items of the set.
最后编辑:2025年06月16日
©著作权归作者所有
最新回复