List is a combination that allows content to be duplicated
A tuple is a combination that allows content to be duplicated
Dict
Set is a combination that does not allow duplication of content, and the contents of the set are arbitrary, so they cannot be listed by index
Set creation:
#The first wayA=set (["a","b","C"])Print(a)#The second wayA=set () A.add ("a") A.add ("b")Print(a)#The Third Way, this way is not a={}a={"a","b","C"}Print(a)
#conversion of Set seta=["AWE","Weg","Dawqgg"]c=set (a)Print(c) B="Chenshuagege"D=Set (b)Print(d) Al=("233","34455") AW=set (AL)Print(AL)
Common methods of Set:
# difference means that content B in a is not, But this does not modify the value of a itself, but instead pays ret the a={ 12 Span style= "COLOR: #800000" > ", " 14 ", " 234 " }b ={ " 12 ", " " }ret = a.difference (b) print (ret)
# difference_update means that content B in a is not, executed, Modifies the contents of a a={ 12 ", " 14 ", " 234 " }b ={ " 12 ", " }a.difference_update (b) print (a)
# Discard is the same as remove, but discard will not give an error, and remove will b={1,23}b.discard (1)print(b)
# take the intersection of the two b={1,23}a={23,5}ret=b.intersection (a)print(ret)
# take the intersection of the two, Intersection_update will change the content of B b={1,23}a={23,5}b.intersection_update (a) Print (b)
b={1,23}a={23,5}# returns False if A and B have a collection, and returns True ret= B.isdisjoint if there is no collection( A)print(ret)
b={1,23,5}a={23,5}#issuperset Description B is the father of a if it is output true if not output falseret= B.issuperset (a)print(ret)
b={1,23,5}a={23,5}#B is the child of a, if it is true, output false ifit is not ret= B.issubset (a)print(ret)
# pop () returns the item that was deleted a={"a","b","C "}ret=a.pop ()print(a)
Python variable set