Set set, which is an unordered and non-repeating collection of elements. Defined in a way similar to a dictionary using {} to create
The types of data we have learned at the moment:
1. String (str), 2. Integer (int), 3. Floating-point (float), 4, List
5. Tuple (tuple), 6. Dictionary (dict), 7. Set (set), 8. Boolean (BOOL)
1. Collection creation
2. Collection Operations
2.1 Set.add adding elements
Add an element to set the element is added only if the element does not exist in the set
2.2 Set.clear Empty all elements
Remove all elements from set
2.3 Set.copy Shallow Copy
2.4 set.difference
Returns a new set made up of two or more different elements in a set
The new set consists of elements that belong to the current set but are not in the other set.
2.5 set.difference_update Remove all elements from the current set from the other set
2.6 Set.discard Delete the specified element, the element does not exist no error
2.7 Set.remove () delete the specified element, the element does not exist the error
2.8 Set.pop randomly specifies that the collection element can be assigned other containers (placeholders)
2.9 set.intersection
Returns the intersection of two or more sets, which is a set of elements that are present in two or more set
3.0 Set.intersection_update
Updates the current set, preserving only those elements that exist in the current set and other set.
3.1 Set.isdisjoint If two set has no intersection, returns true
3.2 Set.issubset Determines whether a set is a subset of the B collection.
3.3 Set.issupreset Determines whether a collection is the parent set of the B collection.
3.4 set. Symmetric_difference returns the difference between a set and B set
3.5 set. Symmetric_difference_update returns the difference set of a and B sets, and updates its own
3.6 Set.union Returns the set of A and B collections
3.7 set.update Update yourself (bulk add function-update)
Classroom tip: Python functions default Calling method
Python Learning notes-day3-set collection operations