python learning DAY6 (collection)

# Set 
unordered
 # - * - Coding: UTF-. 8 - * - 
name = [1,4,5,2,3,2,6,7 ] 
name = SET (name)                   # converted into a set form, and automatic Machining 
NAME2 = sET ([2,6,0,66,22,8,4 ])
 Print (name, NAME2)
 # intersection 
Print (name.intersection (NAME2
 Print (& name NAME2)
 # and set 
Print (name .union (name2))
 Print (name | name2)
 # difference set name2 there is no name in the output 
Print (name.difference (name2))
 Print (name- name2)
 # symmetric difference and the name of the intersection portion removed name2 after remaining two portions taken out
Print (name.symmetric_difference (name2))
 Print (name ^ name2)
 # subset determines whether the name is a subset of name2, if returns true, instead of returning to false 
Print (name.issubset (name2))
 # superset 
Print (name .issuperset (NAME2)) 

# determines whether or not the intersection is not true, the promising to false 
test1 = SET ([l, 2,3 ]) 
test2 = SET ([3,4,5,6 ])
 Print (test1.isdisjoint (test2))   # result is false, because there is an intersection of 3 

# the Add () to add 
a Name.Add (123 ) 

# Update () to add a number of 
name.update ([123,456,789 ]) 

# the remove () to delete specified, if there , error 
name.remove ()
 #pop () deletes random 
name.pop ()
 # discard () Specifies to delete, if there is, do nothing, no error

 

Guess you like

Origin www.cnblogs.com/god-for-speed/p/10994470.html