对于字典中的值的提取 1.简单的字典提取 >>> dict = {"name":"hxy",‘age‘:28} >>> dict[‘name‘] ‘hxy‘ >>> dict[‘age‘] 28 2.字典内的字典值的提取 >>> dict = {"name":[{"name1":"hxy","name2":"forand"}],‘age‘:28} >>> print dict[‘name‘][0] {‘name2‘: ‘forand‘, ‘name1‘: ‘hxy‘} >>> dict = {"name":[{"name1":"hxy","name2":"forand"},{"name1":"hxy","name2":"forand"}],‘age‘:28} >>> print dict[‘name‘][1][‘name2‘] forand >>> dict = {"name":[{"name1":"hxy","name2":"forand"},{"name3":"hxy1","name4":"forand1"}],‘age‘:28} >>> print dict[‘name‘][1][‘name3‘] hxy1
时间: 2024-10-10 03:02:15