Use a dictionary in Python in the following format:
dict={key1:value1, Key2;value2 ...}
The following format is used when the dictionary value is actually accessed:
Dict[key]
Multi-key value
The multiple-key form of a dictionary is as follows:
dict={(KE11,KEY12): Value, (KEY21,KEY22): Value ...}
The actual access to the values in the dictionary is shown as follows (take the first key as an example):
DICT[KEY11,KEY12]
Or is:
dict[(KEY11,KEY12)]
Here is the actual example:
Multi-valued
When a key value corresponds to multiple values, the format:
Dict={key1: (Value1,value2 ...), Key2: (Value1,value2 ...) ...}
The format for accessing the values in the dictionary is as follows:
Dict[key]
Or
Dict[key][index]
Circular Assignment (emphasis)
The syntax structure is as shown in the following example
Knot
By using the instructions above, you know that in the definition of a dictionary, the colon (:) number is a whole before and after, even if you use parentheses () to include the part before and after the colon, when accessing the dictionary value, it is best to place the key in parentheses as a whole.
Multiple key value pairs with the same key value
In the dictionary, a key with at least two members is the same, but the key corresponds to a different value, in the following format:
dict={key1:value1
Key1:vaklue2,
... }
The value that is assigned to the key later in this formal form becomes the true value of the key.
Use lists, dictionaries as values for dictionaries
Format
dict={Key1: (Key11:value,key12:value),
Key2: (Key21:value,key22:value)
}
Access dictionary is worth the formatting (take the first key as an example):
DICT[KEY1][KEY11]
The actual example looks like this:
This article discusses the Python Dictionary of multiple key values and the use of duplicate key values are small series to share all the content, I hope to give you a reference, but also hope that we support the cloud habitat community.