python -- tuples and dictionaries

One : Tuple

Python tuples are similar to lists, except that the elements of the tuple cannot be modified. Use parentheses for tuples and square brackets for lists.

1:1: Format of the tuple

1.2: Accessing tuples 

Fetch data by index

 1.3: Number of queries

count query the number of occurrences

1.4: Query Index 

index : The index of the query element, if there is a corresponding element, the corresponding index will be returned, otherwise an error will be reported

 1.5: Modify data ( cannot be modified )

 1.6: Type Conversion

 1.7: Element loop value

for

 while

 Two: dictionary

2.1: Accessing the dictionary

2.2 New

 2.3: Modification

 2.4: Delete

delete a single

 empty

 2.5: Query length

 2.6 Loop value

 Get the keys from the dictionary

 get the value from the dictionary

  Get the keys and values ​​from the dictionary

The first way:

 The second way:

 Implement index value

 

Guess you like

Origin blog.csdn.net/shitoureng/article/details/124062587