我确实有一个清单,如下所示 -
keyList1 = ["Person", "Male", "Boy", "Student", "id_123", "Name"]
value1 = "Roger"
如何生成可以检索如下的动态字典 -
mydict["Person"]["Male"]["Boy"]["Student"]["id_123"]["Name"] = value
清单可以是任何东西;可变长度或由我不知道的“N”个元素组成......
现在我确实有另一个列表,因此我的字典应该相应更新
keyList2 = ["Person", "Male", "Boy", "Student", "id_123", "Age"]
value2 = 25
即如果键“Person”、“Male”、“Boy”、“Student”、“id_123”已经存在,则应附加新键“age”...