1

I want to ask how to get the list IP Address in my getproject():

addresses={
  'int-ext': [
    {
      'version': 4,
      'addr': '192.168.1.201',
      'OS-EXT-IPS:type': 'fixed',
      'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:e1:95:33'
    }
  ]
},
accessIPv4=,
accessIPv6=

and my code :

data = getproject()

for pj in project:
    for dt in data:
        if pj.project == dt["name"]:
            pj.addr = dt["addresses"]["int-ext"][0]["addr"]

I want to get the IP address and I try to print, but the output still "None" in running code . this code error when I run in python3

jizhihaoSAMA
  • 12,336
  • 9
  • 27
  • 49
Surya
  • 11
  • 2
  • It looks like *name* is not a part of your **json** and *addresses* is a dictionary itself, not a key in the dictionary. – dmitryro Jul 19 '20 at 02:34
  • Can you please include the error seen when you run the script ? Also, Can you please post the full JSON file. In the above, I see that "addresses" is not a string so wanted to confirm the full JSON file. – Prashanth Mariswamy Jul 19 '20 at 02:34
  • Can you provide some more explanation? It's confusing. – Astik Gabani Jul 19 '20 at 02:35
  • this my json data : https://pastebin.com/SJdjH8aB , and I wanna to get the IP Address from int-ext @AstikGabani error script when I print(pj.addr) the output is : None – Surya Jul 19 '20 at 02:44
  • Where are you getting this data from? – bigbounty Jul 19 '20 at 03:01
  • this data from response openstack api list servers. @bigbounty – Surya Jul 19 '20 at 03:05

0 Answers0