本文整理汇总了Python中weather.Weather.lookup_by_location方法的典型用法代码示例。如果您正苦于以下问题:Python Weather.lookup_by_location方法的具体用法?Python Weather.lookup_by_location怎么用?Python Weather.lookup_by_location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weather.Weather
的用法示例。
在下文中一共展示了Weather.lookup_by_location方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: weather_current
# 需要导入模块: from weather import Weather [as 别名]
# 或者: from weather.Weather import lookup_by_location [as 别名]
def weather_current():
weather = Weather(unit=Unit.CELSIUS)
location = weather.lookup_by_location('jaipur')
condition = location.condition
con = f'It\'s {condition.text} today'
temp =f'With temp {condition.temp}𐤏C'
call(['notify-send','-u','normal', con, temp])
示例2: print
# 需要导入模块: from weather import Weather [as 别名]
# 或者: from weather.Weather import lookup_by_location [as 别名]
add1=(response.find("add")+4)
add2=response.find(" to list ")
if os.path.isfile(lstn)==True:
f=open(lstn+".txt", "a+")
f.write(response[add1:add2])
f.close()
elif response == "give me a random number":
print (random.randint(1,100))
elif response == "what is the date":
print (time.strftime (" %A, %B %e, %Y"))
elif "weather " in response:
wthr=(response.find("weather"))
if "weather in " in response:
wthr=((response.find("weather in "))+2)
if wthr not in pycountry.countries:
location = weather.lookup_by_location(response[wthr:(len(response))])
condition = location.condition
print(condition.text)
else:
print("Must be at most a state")
else:
print("where?")
location = weather.lookup_by_location(input("Location: "))
condition = location.condition()
print(condition.text())
elif response=="change name":
print ("what would you like to change the name to?")
myname = input("new name: ")
elif response == "change my name":
print("what would you like to change your name to")
name = input ("new name: ")