=========================================
wget https://launchpad.net/python-weather-api/trunk/0.3.8/+download/pywapi-0.3.8.tar.gz tar -zxvf pywapi-0.3.8.tar.gz cd pywapi-0.3.8/ python setup.py build python setup.py install cd ..
cdoe
import pywapi import string # coding=UTF-8 locate = 'taiwan taipei' locatMap = pywapi.get_location_ids(locate) print locatMap.keys() keylist = [] for key in locatMap.keys(): keylist.append(key) usekey = keylist[0].decode('utf-8') print "search result: "+ usekey+"\n" weather_com_result = pywapi.get_weather_from_weather_com(usekey) yahoo_result = pywapi.get_weather_from_yahoo(usekey) print "Weather.com says: It is " + string.lower(weather_com_result['current_conditions']['text']) + " and " + weather_com_result['current_conditions']['temperature'] + "C now in "+locate + ".\n" print "Yahoo says: It is " + string.lower(yahoo_result['condition']['text']) + " and " + yahoo_result['condition']['temp'] + locate+".\n"
沒有留言:
張貼留言