📜  在 python 代码示例中使用用户输入创建嵌套字典

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

代码示例1
d = {}

size = int(input("Enter the size of nested dictionary: "))
for i in range(size):
    
    dict_name = input("Enter the name of child dictionary: ")
    d[dict_name] = {}
    Name = input("Enter name: ")
    Age = input("Enter Age: ")
    d[dict_name]["Name"] = Name
    d[dict_name]["Age"] = Age
    
print(d)