# function: Go heavy, relational operation,
Custom
# 1: Each element must be an immutable type (hash, can be used as the dictionary key)
# 2: No duplicate elements
# 3: Unordered
# s={1,2, ' A ', ' B ', ' C ', ' d ', ' e ', ' f '} #s =set ({, ' a '})
# print (type (s), s)
# Priority operations:
# length Len
# s={1,2, ' A ', ' B ', ' C ', ' d ', ' e ', ' f '}
# print (len (s))
# member operations in and not in
# print (' A ' in s)
# for item in S:
# Print (item)
# | and set
# s1={1,2,3}
# s2={3,4,5}
# print (S1 | s2)
# & Intersection
# print (S1 & S2)
#-Difference Set
# Print (S1-S2)
# Print (S2-S1)
# ^ Symmetric difference set
# s1={1,2,3}
# s2={3,4,5}
# ==
# >, >=, <, <= parent set, subset
# s1={1,2,3,4}
# s2={3,4,5}
# print (len (S1) > Len (s2))
# s1={1,2,3,4}
# s2={3,4}
# print (S1 > S2)
# print (S1 >= S2)
#常用操作
s1={1,2,3, ' A ', 4}
# Print (S1.pop ()) #随机删 and returns the result of the deletion
# s1.remove (' a ') #单纯地删, will not return the result of the deletion, and if the deleted element does not exist then an error
# s1.remove (' Asdfasdfa ') #单纯地删, will not return the result of the deletion
# print (S1)
# Print (S1.discard (' a ')) #单纯地删, will not return the result of the deletion, and if the deleted element does not exist return none, no error
# print (S1)
# s1.add (' B ')
# print (S1)
s1={1,2,3}
s2={4,5}
# Print (S1.isdisjoint (S2)) #如果s1和s2没有交集则返回True
#了解
# s1={1,2,3,4}
# s2={3,4,5}
# | and set
# Print (s1.union (S2))
# & Intersection
# Print (s1.intersection (S2))
# s1.intersection_update (S2) #s1 =s1.intersection (S2)
# print (S1)
#-Difference Set
# Print (s1.difference (S2))
# ^ Symmetric difference set
# Print (s1.symmetric_difference (S2))
# ==
# >, >=, <, <= parent set, subset
# s1={1,2,3,4}
# s2={3,4}
# Print (S1.issuperset (S2))
# Print (S2.issubset (S1))
Go heavy
# l=[' A ', ' B ', 1, ' A ', ' a ']
# Print (List (set (L)))
# l=[' A ', ' B ', 1, ' A ', ' a ']
# l_new=list ()
# S=set ()
# for item in L:
# If Item not in S:
# S.add (item)
# L_new.append (item)
l=[
{' name ': ' Egon ', ' age ':, ' sex ': ' Male '},
{' name ': ' Alex ', ' age ': ' I ', ' sex ': ' Male '},
{' name ': ' Egon ', ' age ': ' Sex ': ' Female '},
{' name ': ' Egon ', ' age ':, ' sex ': ' Male '},
{' name ': ' Egon ', ' age ':, ' sex ': ' Male '},
]
L_new=list ()
S=set ()
For item in L:
res = (item[' name '], item[' age '], item[' sex ')
If res not in S:
S.add (RES)
L_new.append (item)
Print (l_new)
#了解: Immutable Collections
Fset=frozenset ({A-i})
Fset.
The learning journey of Python ——— basic data Type (collection type)