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


Python Weather.lookup_by_location方法代码示例

本文整理汇总了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])
开发者ID:ShivSoni5,项目名称:Vision,代码行数:9,代码来源:forecast.py

示例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: ")
开发者ID:ultimatepritam,项目名称:Jarvis,代码行数:33,代码来源:Jarvia.py


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