python字典里套字典
Posted 芽衣
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python字典里套字典相关的知识,希望对你有一定的参考价值。
在一个字典里再套字典。
familyinfo = { "family name":"Python", "family structure":[ {"name":"Taro", "age":32, "sex":"male"}, {"name":"Hanako", "age":31, "sex":"female"}, {"name":"Ichiro", "age":5, "sex":"male"} ], "address":[ {"country":"Japan"}, {"administrative_area":"Tokyo"}, {"locality":"Chuohku"} ], "phone number":"03-0000-0000" }
想要打印“Taro”的话
print(familyinfo["family structure"][0]["name"])
以上是关于python字典里套字典的主要内容,如果未能解决你的问题,请参考以下文章