import urllib, json
def Forecast(location):
baseurl = "https://query.yahooapis.com/v1/public/yql?"
yql_query = "select * from weather.forecast where woeid in (select woeid from geo.places(1) where text='"+location+"')"
yql_url = baseurl + urllib.urlencode({'q':yql_query}) + "&format=json"
result = urllib.urlopen(yql_url).read()
data = json.loads(result.decode())
for it in data['query']['results']['channel']['item']['forecast']:
weather_code = it['code']
print (it['date']+"--"+it['day']+"--"+it['high']+"--"+it['low']+"--"+it['text']+"--<img src='http://l.yimg.com/a/i/us/we/52/"+weather_code+".gif' />")