I try to get the key to the value I'm returning with, but when I use a simple approach to just get the value of a specific key, I get an error: TypeError: string indices should be integers, not str
I also tried the .get () method, but it didn't work either. Can someone tell me what I am doing wrong?
>>> import urllib2 >>> url = 'http://192.168.250.1/ajax.app?SessionId=8ef05397-ef00-451a-bc1c-c0d61 5a4811d&service=getDp&plantItemId=1413' >>> response = urllib2.urlopen(url) >>> dict = response.read() >>> dict '{"service":"getDp","plantItemId":"1413","value":" 21.4","unit":"\xc2\xb0C"}' >>> dict['value'] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: string indices must be integers, not str
source share