Aussi appelé hash C'est un ensemble de clés et de valeurs.
La mise en garde est d'utiliser {}.
city = {"Clé 1": "Valeur 1", "Clé 2": "Valeur 2"}
Appelez en spécifiant la clé.
dic ={"book": "kokugo", "name": "yamada"}
print(dic["book"])
#production: kokugo
Écraser
dic ={"book": "kokugo", "name": "yamada"}
dic["book"] = "sugaku"
print(dic)
#production: {"book": "suugaku", "name": "yamada"}
ajouter à
dic ={"book": "kokugo", "name": "yamada"}
dic["seibetu"] = "men"
print(dic)
#production: {"book": "kokugo", "name": "yamada", "seibetu": "men"}
Effacer
dic = {"book": "kokugo", "name": "yamada", "seibetu": "men"}
del dic["book"]
#Supprimer l'élément spécifié
print(dic)
#production: {"name": "yamada", "seibetu": "men"}
Recommended Posts