本文整理汇总了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