循环遍历所有嵌套的字典值?
for k, v in d.iteritems(): if type(v) is dict: for t, c in v.iteritems(): print "{0} : {1}".format(t, c)
def printDict(d): for k, v in d.iteritems(): if type(v) is dict: printDict(v) else: print "{0} : {1}".format(k, v)
{u'xml': {u'config': {u'portstatus': {u'status': u'good'}, u'target': u'1'}, u'port': u'11'}}
xml : {u'config': {u'portstatus': {u'status': u'good'}, u'target': u'1'}, u'port': u'11'}
ibeautiful
明月笑刀无情
相关分类