예제 #1
0
def example1(apikey):
  locations = ['Amsterdam,NL', 'Philadelphia, PA', 'Kiyv,Ukraine', 'Rio de Janeiro, Brazil', 'Berlin, Germany', 'Sydney, Australia']

  weather = forecast_io(apikey, units = 'si')
   
  print("%-25s %s %s %s %s %s" % ('location', "temperature", "time", "humidity", "windSpeed", "summary"))
  for location in locations:
    weather.setLocation(location)
    weather_list = weather.getParameterizedWeather(['temperature', 'time', 'humidity', 'windSpeed', 'humidity', 'summary' ])
    print("%-25s" % location),
    for param in weather_list:
      print param,
    print ""
예제 #2
0
def example3(apikey):

  city = 'Los Angeles, CA'
  weather = forecast_io(apikey, units = 'si')
  weather.setLocation(city)
  weather.getWeather("daily")

  data = weather.result

  print("Sunrise in %s was at %s. Day maximum: %.2fC. Day minimum %.2fC. Summary: %s" % (
      city, 
      time.strftime("%H:%M:%S", time.localtime(int(data['sunriseTime']))), 
      data['temperatureMax'],
      data['temperatureMin'],
      data['summary']
      )
  )
예제 #3
0
def example2(apikey):
  weather = forecast_io(apikey, units = 'si')
  weather.setLocation('New York, NY')
  weather.getWeather('daily')
  print json.dumps(weather.result)