1. 程式人生 > >【python】字典裏套字典

【python】字典裏套字典

python family nis num hana ctu span ber info

在一個字典裏再套字典。

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】字典裏套字典