How to display specific parts of json?
<p>Can someone help me with this python api calling program? </p>

<pre><code>import json
from pprint import pprint
import requests
weather = requests.get('http://api.openweathermap.org/data/2.5/weather?    
q=London&amp;APPID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
pprint(weather.json())

wjson = weather.read()
wjdata = json.load(weather)
print (wjdata['temp_max'])
</code></pre>

<p>So with this piece of code I'm trying to get information from the weather api it prints it properly but when I want to select certain values only I get this error.</p>

<pre><code>Traceback (most recent call last):
  File "gawwad.py", line 7, in &lt;module&gt;
    wjson = weather.read()
AttributeError: 'Response' object has no attribute 'read'
</code></pre>

<p>alecxe is correct with using the json library, if you want to know more about referencing specific values in a json object, look into pythons Dictionary data types. That is what json essentially converts them into.</p>

<p><a href="https://docs.python.org/3/tutorial/datastructures.html#dictionaries" rel="nofollow">https://docs.python.org/3/tutorial/datastructures.html#dictionaries</a></p>

<p>The link above will show you how to use them!! Dictionaries are 'key-value' data structures where keys are unique and must not be hashable, and values are any type.</p>

<p>python Dictionary quick example: </p>

<pre><code>dict = {'keyA' : 'valueA', 'keyB': 'valueB'}
# To reference a value, use the key!
print(dict['keyA'])
# To add something
dict['keyC'] = 'valueC'
# now my dictionary looks like this
dict = {'keyA' : 'valueA', 'keyB': 'valueB', 'KeyC' : 'valueC'}
</code></pre>

<p>The print statement will output, 'valueA'</p>

python json api