python - How to get data from list with dictionary -


hello have python variable list plus dictionary

 >>> print (b[0])     {'peer': '127.0.0.1', 'netmask': '255.0.0.0', 'addr': '127.0.0.1'} -----------------------------------------------------------------------    >>> print (b) [{'peer': '127.0.0.1', 'netmask': '255.0.0.0', 'addr': '127.0.0.1'}] >>> 

i have tried couldn't 'addr' extracted.

help please.

try this:

print (b[0]['addr']) 

print(b[0]) gives dictionary, in dictionary can fetch value key dict[key] => returns associated value.

so print(b[0]['addr']) give value of addr

read python data structure here data structure


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -