Str
List---Lists
Tuple
DIC----Dictionary
Set
Function
-Custom functions
-built-in functions > Python-provided functions that call directly
Depth copy
Decorative Device
List characteristics: Ordered, the elements can be repeated, the dictionary key cannot be duplicated;
1.set-unordered, non-repeating sequence;
Cases:
List = [11,22,11,22]--Types of lists
DIC = {"K1": 123}--Dictionary type
A. Creating a set collection (function)
SE = {"123", "456"}--collection type
Print (Type (set))
List ()--class after addition () parentheses, which represents the invocation of the __init__ method;
list__init__, internal execution for loop (11,22,33,44) List--[11,22,33,44]
S1 = {11,22}
S2 = set ()
S3 = Set ([11,22,33,44])
B. function
s = Set () creates an empty collection;
To convert a list to a collection:
List = [11,22,11,22]
S1 = set (list)
Print (S1)
Operation Collection:
S1 = set ()
S1. Add (123)
Print (S1)
S1.clear ()
Print (S1)
S2 = {121,3132,22,11}
S1.difference (S2)
S3 = s1.symmetric_difference (S2)
Print (S3)
S1.discard (123)--Remove the specified element
S1.pop ()--random removal of an element
ret = S1.pop ()---Remove an element and assign the element to RET
S1.update (list)--iterate to add elements
Python's Set function