📜  字典 python 代码示例

📅  最后修改于: 2022-03-11 14:45:26.364000             🧑  作者: Mango

代码示例6
#A dictionary has key-value pairs. Here 1,2,3 are the keys and Item1,Item2,Item3 
#are their values respectively. 
dictionaryName = { 1: "Item1", 2: "Item2", 3: "Item3"}

#retrieving value of a particular key
dictionaryName[1]

#retrieving all the keys in a dictionary
dictionaryName.keys()

#retrieving all the values in a dictionary
dictionaryName.values()