umbrella.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Jarvis 作者: sukeesh 项目源码 文件源码
def main(city=0):
    if not city:
        city = getLocation()['city']
    send_url = (
        "http://api.openweathermap.org/data/2.5/forecast/daily?q={0}&cnt=1"
        "&APPID=ab6ec687d641ced80cc0c935f9dd8ac9&units=metric".format(city)
    )
    r = requests.get(send_url)
    j = json.loads(r.text)
    rain = j['list'][0]['weather'][0]['id']
    if rain >= 300 and rain <= 500:  # In case of drizzle or light rain
        print(Fore.CYAN + "It appears that you might need an umbrella today." + Fore.RESET)
    elif rain > 700:
        print(Fore.CYAN + "Good news! You can leave your umbrella at home for today!" + Fore.RESET)
    else:
        print(Fore.CYAN + "Uhh, bad luck! If you go outside, take your umbrella with you." + Fore.RESET)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号