嗨,我的代码里有一本字典。在nrec={'bridge': 'xapi1', 'current_operations': {}, 'uuid': '9ae5ca7d-e7d6-7a81-f619-d0ea33efb534', 'tags': [], 'other_config': {'is_guest_installer_network': 'true', 'netmask': '255.255.255.0', 'ip_end': '192.168.128.254', 'ip_begin': '192.168.128.1'}, 'name_label': 'Guest installer network', 'VIFs': ['OpaqueRef:dff106aa-1a94-8384-1c86-862b47c87fcf'], 'allowed_operations': [], 'PIFs': [], 'name_description': 'Network on which guests will get assigned a private local IP address', 'MTU': '1500', 'blobs': {}}
在这里你可以看到这本字典里面还有一本字典'other_config': {'is_guest_installer_network': 'true', 'netmask': '255.255.255.0', 'ip_end': '192.168.128.254', 'ip_begin': '192.168.128.1'}。在
我想查一下is_guest_installer_network=="true"
我已经完成了nrec["other_config"]["is_guest_installer_network"]== "true",但问题是某些属性的另一个配置属性的值为空或值不同。在这种情况下,我的解决方案将抛出异常。所以我想用一种有效的方法来做,比如If is_guest_installer_network is includes in the dictionary and the value(string)is true or not。在