如何在 Python 中定义字典中的字典?
字典对象是可变的。因此,一个字典对象可以用作键的值组件。所以我们可以创建一个嵌套字典对象,另一个字典对象被定义为与键相关联的值。
>>>> students={"student1":{"name":"Raaj", "age":23, "subjects":["Phy", "Che", "maths"],"GPA":8.5},"student2":{"name":"Kiran", "age":21, "subjects":["Phy", "Che", "bio"],"GPA":8.25}}
广告