#!/usr/bin/env python tree_dic = { 'id':1, 'name':'aaaa', 'node':{ 'id':2, 'node':{ 'id':3, 'name':'aaaa', 'node':{ 'id':4, 'node':{ 'id':5, 'name':'aaaa', } } } } } def tree_search(s): name = 'aaaa' for k,v in s.items(): if type(v) == dict: tree_search(v) else: if v == name : print s[k] tree_search(tree_dic)
分类:Python
标签: