How to Access Dictionary Values in Python -


please me access dictionary value :

result = {     u'responsedata': {         u'cur': {             u'moreresults': u'myresulthere',              u'resultcount': u'4',             u'time': u'0.10',             u'count': u'4',              u'page': [{u'start': u'0', u'label': 1}],              u'currentindex': 0         },          u'results': [{u'gclass': u'gch',                        u'visible': u'slobaexper',                       u'formatting': u'slobog'                      }]     },       u'redetails': none,     u'restatus': 200 } 

i want access "results" value. when :

print 'results' in result.keys() 

it prints false though exists.

when :

def gplag(text,encode=false): import urllib, urllib2, json if encode == true:     text = text.encode('utf-8') query = urllib.quote_plus(text) base_url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=' url = base_url + '%22' + query + '%22' request = urllib2.request(url,none) response = urllib2.urlopen(request) result = json.load(response) output = [] if result['responsedata']['results'] != []:     firstmatch = result['responsedata']['results'][0]     output.append(firstmatch['title'])     output.append(firstmatch['visibleurl'])     output.append(firstmatch['content']) return output  def callgplag(n):     s in n:         outcome = gplag(s,encode=true) 

it gives typeerror: 'nonetype' object has no attribute '_getitem_' in if result['responsedata']['results'] line

results inside of data.

print result['data']['results'] print 'results' in result['data'] 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -