本文整理汇总了Python中weather.Weather.lookup方法的典型用法代码示例。如果您正苦于以下问题:Python Weather.lookup方法的具体用法?Python Weather.lookup怎么用?Python Weather.lookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weather.Weather
的用法示例。
在下文中一共展示了Weather.lookup方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getWeather
# 需要导入模块: from weather import Weather [as 别名]
# 或者: from weather.Weather import lookup [as 别名]
def getWeather(forecastIndex):
weather = Weather()
lookup = weather.lookup(26237347) #TKO
#condition = lookup.condition()
forecasts = lookup.forecast()
#0 is today, 1 is tomorrow, etc...
f = forecasts[forecastIndex]
return f.text() + ": hight " + str(f2c(f.high())) + " / low " + str(f2c(f.low()))
示例2: getWeather
# 需要导入模块: from weather import Weather [as 别名]
# 或者: from weather.Weather import lookup [as 别名]
def getWeather(forecastIndex):
weather = Weather(unit=Unit.CELSIUS)
lookup = weather.lookup(26237347) #TKO
#condition = lookup.condition()
forecasts = lookup.forecast
#0 is today, 1 is tomorrow, etc...
f = forecasts[forecastIndex]
# return [f.text, f2c(f.high), f2c(f.low)]
return [f.text, float(f.high), float(f.low)]
示例3: Weather
# 需要导入模块: from weather import Weather [as 别名]
# 或者: from weather.Weather import lookup [as 别名]
For color output
$ pip3 install colorama
WOEID for Lexington, KY is 12775316
"""
from weather import Weather, Unit
from colorama import Fore, Style
import os
# To clear the screen
cls = os.system('clear')
weather = Weather(unit=Unit.FAHRENHEIT)
lookup = weather.lookup(12775316)
condition = lookup.condition
place = lookup.title
forecasts = lookup.forecast
print(Style.BRIGHT)
print("\n" + "Weather for " + place + "\n")
print("Today's date: " + "\t\t\t" + condition.date)
print("Current conditions: " + "\t\t" + condition.text)
print("Current temperature: " + "\t\t" + condition.temp + "F")
print("\n" + "Forecast for Lexington, KY:" + "\n")
for forecast in forecasts:
print(Fore.MAGENTA + forecast.date + "\t" +
Fore.WHITE + "High temp: " + forecast.high + "F" + "\t" +
"Low temp: " + forecast.low + "F" + "\t" +
示例4: getWeather
# 需要导入模块: from weather import Weather [as 别名]
# 或者: from weather.Weather import lookup [as 别名]
def getWeather():
weather = Weather()
lookup = weather.lookup(26237347) #TKO
condition = lookup.condition()
return condition