Container:
List and Ganso
Difference:
The list can be modified, and the meta-ancestor cannot
Sequence: List, Ganso (each element in the sequence has its own ID (number), numbering starts from 0 to the right)
Common:
Index:
Eg:name= ' Jack ', name[0]= ' J '
Note: You can also direct ' Jack ' [0]= ' J '
Sharding:
Provides two indexes as a boundary, the element of the first index is contained within the Shard, and the second is not contained within the Shard.
eg:numbers=[0,1,2,3,4,5,6,7,8,9], then numbers[0:3]=[0,1,2]
Shortcut: numbers[:] is equal to the entire sequence
Step: eg:numbers[0:5:2]=[0,2,4], where the step size is set to 2
Note: For a positive step, Python extracts the element to the right from the head of the sequence until the last element, and for a negative step, the
The tail of the sequence begins to extract elements to the left until the first element
Addition:
Note: Only two sequences of the same type can be connected.
eg:[1,2,3]+[4,5,6] = [1,2,3,4,5,6]
' Hello, ' + ' Python ' = ' Hello,python '
error:[1,2,3]+ ' Hello ' (Error)
Multiplication:
Multiplying the number x by a sequence creates a new sequence, and in the new sequence, the original sequence is repeated x times.
eg: ' Hello ' *3= ' Hellohellohello '
Membership:
In order to check whether a value is in a sequence, you can use the In operator to return a value of true or false.
eg:permission= ' rwx '
' R ' in permission, returns True
Characteristics:
Change the list:
Eg:data = [1,1,1,1,1]
data[1]=2, this sentence changes the list, changing the list to [1,2,1,1,1]
Del Data[2], remove the 3rd element of the list, and change the list to [1,2,1,1]
Map: Dictionary (each element in the map has its own key)
Collection:
List and Ganso of the Python series