Created
January 29, 2011 03:44
-
-
Save yurenju/801493 to your computer and use it in GitHub Desktop.
tw-weather.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import pywapi | |
cities = pywapi.get_cities_from_google('tw', 'zh-tw') | |
for c in cities: | |
print "%s: " % (cities.index(c)+1), | |
print c['name'] | |
num = int (raw_input ("type: ")) | |
city = cities[num-1] | |
weather = pywapi.get_weather_from_google(',,,%s,%s' % (city['latitude_e6'], city['longitude_e6']), 'zh-tw') | |
print "天氣:%s" % weather['current_conditions']['condition'].encode ('utf-8') | |
print "濕度:%s" % weather['current_conditions']['humidity'].encode ('utf-8') | |
print "現在溫度:%s" % weather['current_conditions']['temp_c'].encode ('utf-8') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment