Automatisch hinzufügen-Taste, um Python-dict

Möchte ich automatisch hinzufügen Schlüssel zu einem Python-Wörterbuch, wenn Sie nicht bereits vorhanden sind.
Zum Beispiel,

a = "a"
b = "b"
c = "c"

dict = {}
dict[a][b] = c # doesn't work because dict[a] doesn't exist

Wie kann ich automatisch erstellen-Schlüssel, wenn Sie nicht existieren?

  • egidra = EGIdrA = SC2? +1 auf den Namen allein
  • yup, haha
InformationsquelleAutor egidra | 2012-10-31
Schreibe einen Kommentar