本文整理匯總了Python中weather.Weather方法的典型用法代碼示例。如果您正苦於以下問題:Python weather.Weather方法的具體用法?Python weather.Weather怎麽用?Python weather.Weather使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weather
的用法示例。
在下文中一共展示了weather.Weather方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: query_weather
# 需要導入模塊: import weather [as 別名]
# 或者: from weather import Weather [as 別名]
def query_weather(self,city):
weather = Weather()
location = weather.lookup_by_location(city)
res = ""
forecast = location.forecast()
for forecasts in forecast:
res += 'Date: ' + forecasts.date() + '\nCondition: ' + forecasts.text() + '\nHigh Temperature (F): ' + forecasts.high() + '\nLow Temperature (F): ' + forecasts.low() + '\n\n'
return res
示例2: run
# 需要導入模塊: import weather [as 別名]
# 或者: from weather import Weather [as 別名]
def run(self, dispatcher, tracker, domain):
weather = Weather(unit=Unit.CELSIUS)
gpe = ('Auckland', tracker.get_slot('GPE'))[bool(tracker.get_slot('GPE'))]
result = weather.lookup_by_location(gpe)
if result:
condition = result.condition
city = result.location.city
country = result.location.country
dispatcher.utter_message('It\'s ' + condition.text + ' and ' + condition.temp + '°C in ' +
city + ', ' + country + '.')
else:
dispatcher.utter_message('We did not find any weather information for ' + gpe + '. Search by a city name.')
return
示例3: __init__
# 需要導入模塊: import weather [as 別名]
# 或者: from weather import Weather [as 別名]
def __init__(self, config):
# Save the parsed config
self.config = config
# Parse today's date and see if we should use today or yesterday
self.set_current_date()
# Flag to determine when to refresh data
self.needs_refresh = True
# Fetch the games for today
self.refresh_games()
# Fetch all standings data for today
# (Good to have in case we add a standings screen while rotating scores)
self.refresh_standings()
# What game do we want to start on?
self.current_game_index = self.game_index_for_preferred_team()
self.current_division_index = 0
# Network status state
self.network_issues = False
# Weather info
self.weather = Weather(self.config.weather_apikey, self.config.weather_location, self.config.weather_metric_units)
# News headlines
self.headlines = Headlines(self.config)
#
# Date