Obviously the key can only correspond to one value. If the key corresponds to multiple values, when you get the key at a certain moment, the computer will not know which value you want. The principle of key-value is that the value is variable, but the key is only constant. Just like a house number, this house number indicates a certain house in this location. Value is the person living in the house. The house can change its owner, which means we assign different values to value. The one value mentioned above can correspond to multiple keys is not easy to explain with this example. It can be simply understood that two keys can be equal to the same value.
If the key is a person, the value can be the person's name. A person may have multiple names, but there is no second identical person in the world (key uniqueness). There are many people with the same name and surname, but People who are all different from each other (the keys are different, the values can be the same, one name corresponds to n people). The individual ID is key: the name is value. This is a dictionary (key-value pair).
Key cannot be repeated in a Dictionary, but Value can be repeated
A key can only be paired with one value, and one value can be paired with n keys
Obviously the key can only correspond to one value. If the key corresponds to multiple values, when you get the key at a certain moment, the computer will not know which value you want. The principle of key-value is that the value is variable, but the key is only constant. Just like a house number, this house number indicates a certain house in this location. Value is the person living in the house. The house can change its owner, which means we assign different values to value. The one value mentioned above can correspond to multiple keys is not easy to explain with this example. It can be simply understood that two keys can be equal to the same value.
If the key is a person, the value can be the person's name. A person may have multiple names, but there is no second identical person in the world (key uniqueness). There are many people with the same name and surname, but People who are all different from each other (the keys are different, the values can be the same, one name corresponds to n people). The individual ID is key: the name is value. This is a dictionary (key-value pair).