Reputation: 13
Code:
response = requests.request("GET", url, headers=headers, params=querystring)
print(json.dumps(response.json(), indent=4))
Output:
{
"errors": [],
"result": [
{
"hex": "18:93:d7",
"b16": "1893d7",
"name": "texas instruments",
"address": "12500 ti blvd dallas tx 75243 us"
}
]
}
My Goal:
I want to only print hex, name & address. i want to prettify it aswell but before i do that i need to filter the output
Upvotes: 1
Views: 111
Reputation: 384
for i in 'hex', 'name', 'address':
print(i.capitalize(), response.json()['result'][0][i])
and you'll get:
Hex 18:93:d7
Name texas instruments
Address 12500 ti blvd dallas tx 75243 us
Upvotes: 1