在一个字典里再套字典。
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"])
时间: 2024-11-10 00:30:56