Skip to content Skip to sidebar Skip to footer

Extract Data From Json From An Api With Python

The data under consideration is coming from an API, which means that it's highly inconsistent- sometimes it pulls unexpected content, sometimes it pulls nothing, etc. What I'm int

Solution 1:

'ISO3166-2' is dictionary value, not key

codes = response.get('codes', [])
for code in codes:
    if code.get('type') == 'ISO3166-2':
        print('{}-{}'.format(response.get('countryCode', 'UNKNOWN'), code.get('code', 'UNKNOWN')))

Post a Comment for "Extract Data From Json From An Api With Python"