json - No results from API call in python -


my api call in python returns no results. exits code 0 there nothing displayed. there missing? still new python , got code youtube tutorial. using own api key. here code:

#!/usr/bin/env python #learn how works here: http://youtu.be/pxofwuwts7c  import urllib.request import json  locu_api = 'xxxxxxxxxxxx'  def locu_search(query):     api_key = locu_api     url = 'https://api.locu.com/v1_0/venue/search/?api_key=' + api_key     locality = query.replace(' ', '%20')     final_url = url + "&locality=" + locality + "&category=restaurant"     json_obj = urllib2.urlopen(final_url)     data = json.load(json_obj)     item in data['objects']:         print (item['name'], item['phone']) 

your script defines function locu_search, not calling it; script terminates - having done nothing of value.

you need call function after defined, like:

def locu_search(query):     #snip  locu_search('san francisco') 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -