当前位置: 首页>>代码示例>>Python>>正文


Python weather.Weather方法代码示例

本文整理汇总了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 
开发者ID:mkfeuhrer,项目名称:JarvisBot,代码行数:12,代码来源:jarvisBot.py

示例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 
开发者ID:MartinGentleman,项目名称:weather-bot,代码行数:15,代码来源:weather.py

示例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 
开发者ID:MLB-LED-Scoreboard,项目名称:mlb-led-scoreboard,代码行数:35,代码来源:data.py


注:本文中的weather.Weather方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。