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 ofaddr
read python data structure here data structure
Comments
Post a Comment