Function:
One, you can remove the list, duplicate items in the tuple
Second, can be used for intersection, collection, difference set, etc.
def add (self, *args, **kwargs):
"" Add " " "
S1 = (1,2,3 , 4,2,3,1)
S3 = set ( s1)
S4 = S3.add (5)
print ( s1)
print (S3)
print (S4)
(1, 2, 3, 4 , 2, 3, 1)
{1, 2, 3, 4, 5}
None
def clear (Self, *args, **kwargs):
"Clear all elements"
S1 = (1,2,3,4,2,3,1)
Set (s1)
S4 = S3.clear ()
Print (s1)
Print (S3)
Print (S4)
(1, 2, 3, 4, 2, 3, 1)
Set ()
Non
def copy (self, *args, **kwargs):
"Copy a Set"
S1 = (1,2,3,4,2,3,1)
Set (s1)
S4 = S3.copy ()
Print (s1)
Print (S3)
Print (S4)
(1, 2, 3, 4, 2, 3, 1)
{1, 2, 3, 4}
{1, 2, 3, 4}
def difference (self, *args, **kwargs):
"' A.difference (b) A and B differential set, showing the result of a" '
S1 = (1,2,3 , 4,2,3,1)
S2 = (3,4,5,< Span style= "color: #0000ff;" >7,1)
S5 = set (s2)
S3 = set ( s1)
S4 = s3.difference (s2)
print (S3)
print (S5)
print (S4)
{1, 2, 3, 4}
{1, 3, 4, 5, 7}
{2}
def difference_update (self, *args, **kwargs):
" Delete all elements contained in B in the current A, and delete the ' '
directly in the original collection
S1 = (1,2,3 , 4,2,3,1)
S2 = (3,4,5,< Span style= "color: #0000ff;" >7,1)
S5 = set (s2)
S3 = set ( S1)
print (s3)
S4 = S3.difference_ Update (s2)
print (S3)
print (S5)
print (S4)
{1, 2, 3, 4}
{2}
{1, 3, 4, 5, 7}
None
def discard (self, *args, **kwargs):
' ' removes elements from the collection and removes ' '
directly from the original collection
S1 = (1,2,3 , 4,2,3,1)
S2 = (3,4,5,< Span style= "color: #0000ff;" >7,1)
S5 = set (s2)
S3 = set ( S1)
print (s3)
S4 = S3.discard (2)
print (S3)
print (S5)
print (S4)
{1, 2, 3, 4}
{1, 3, 4}
{1, 3, 4, 5, 7}
None
def intersection (self, *args, **kwargs):
" "" take intersection, create a new set ""
S1 = (1,2,3 , 4,2,3,1)
S2 = (3,4,5,< Span style= "color: #0000ff;" >7,1)
S5 = set (s2)
S3 = set ( S1)
print (S3)
print (s5)
S4 = s3.intersection (S5)
print (S3)
print (S4)
{1, 2, 3, 4}
{1, 3, 4, 5, 7}
{1, 2, 3, 4}
{1 , 3, 4}
def intersection_update (self, *args, **kwargs):
" Take the intersection and modify the original set '
S1 = (1,2,3 , 4,2,3,1)
S2 = (3,4,5,< Span style= "color: #0000ff;" >7,1)
S5 = set (s2)
S3 = set ( S1)
print (S3)
print (s5)
S4 = S3.intersection_update (S5)
Print (S3)
print (S4)
{1, 2, 3, 4}
{1, 3, 4, 5, 7}
{1, 3, 4}
None
def isdisjoint (self, *args, **kwargs):
" '
S1 = (1,2,3,4,2,3,1)
S2 = ( Span style= "color: #0000ff;" >3,4,5,7,1)
S5 = set (s2)
S3 = set (S1)
print (S3)
print (s5)
S4 = S3.isdisjoint (S5)
print (S3)
print (S4)
{1, 2, 3, 4}
{1, 3, 4, 5, 7}
{1, 2, 3, 4}
False
def issubset (self, *args, **kwargs):
"' is a subset '
""""""
def pop (self, *args, **kwargs):
' remove '
""""""
"" " difference set, create new Object " ""
def symmetric_difference_update (self, *args, **kwargs):
""""""
""""""
""""""
Set set (set is an unordered and non-repeating collection of elements)