Skip to content

Instantly share code, notes, and snippets.

@yurenju
Created January 29, 2011 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yurenju/801493 to your computer and use it in GitHub Desktop.
Save yurenju/801493 to your computer and use it in GitHub Desktop.
tw-weather.py
#!/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