當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。