Accessing dictionary of dictionary in python

后端 未结 7 511
醉梦人生
醉梦人生 2021-01-22 09:47

Hi in my code there is a dictionary of dictionary.

nrec={\'bridge\': \'xapi1\', \'current_operations\': {}, \'uuid\': \'9ae5ca7d-e7d6-7a81-f619-d0ea33efb534\', \         


        
相关标签:
7条回答
  • 2021-01-22 10:19

    One possible solution is

    >>> try:
        if nrec["other_config1"]["is_guest_installer_network"] == 'true':
            print 'Do Something'
    except (KeyError,TypeError):
        None #Or do something logical
    
    0 讨论(0)
提交回复
热议问题