python1.3 collection of knowledge:

# Define the set: {} key set is not only the value of the dictionary, the set of elements can not be repeated!
1,2,3,4,5,6} = {A
# listing converted into a set
B = SET ([1,2,3,4,5])
Print (A, B)

# Re-set to the list
List1 = [1,1,2,2,3,4,5,6,7,8]
# converted into a set
X SET = (List1)
# reduced to a list of
y = list (x)
print (y)

# Set operation
C = {1,2,3,4,5,6,7}
D = {4,5,6,7,8,9,0}
# set difference (to remove common elements in the set C)
Print (CD)
# combiner (two set of combined all the elements)
Print (C | D)
# set post (extract common elements two set)
Print (C & D)
# set symmetric difference (to remove the same elements as two set then combined)
Print (c ^ d)

 

Guess you like

Origin www.cnblogs.com/lma0702/p/11106277.html