There are four most commonly used data structures in Python, namely list, dictionary (dict), set (set), and tuple (tuple)
Below is a brief description of their differences and connections
1. Initialization
It has to be said that Python data structures are much simpler to initialize than Java.
List=[]
dict={}
Tuple= (1, 2,)
Set= ([i])
After initialization, the print set result is: {dict}, it can be found that the set is not the value of the
2. Is it orderly
List and tuple are ordered, dict and set are unordered
3. Whether variable
Once a tuple is initialized, it can be accessed as a list by subscript, but cannot be changed, and List/dict/set are mutable.
The set is variable and can be deleted by adding (), remove (), or the intersection of two sets, and the operation of a set
4. Can I have duplicate elements
List,tuple can have
Set can not have duplicate elements
The value of dict can be repeated, but key cannot be
Python Common data structures