/shape_Ai_project_Vishakha_goyal

import requests import os from datetime import datetime userAPI = "0f2585f6544ef75a6f06304e1ecc1b8d" location = input("Enter The City Name :- ") completeAPIlink = "https://api.openweathermap.org/data/2.5/weather?q={}&appid={}" api_link = requests.get(completeAPIlink) api_data = api_link.json() if api_data["cod"] == "404": print("Invalid City :- {}, Please check your city name".format(location)) else: temp_city = ((api_data ["main "]['temp'])-273.15) wethr_des = api_data['weather'][0][' description '] humdt = api_data["main"]['humidity'] wind_spd = api_data['wind']['speed'] date_time = datetime.now().strftime("%d %b %Y | %I:%M %S %p") print("-------------------------------------------------------------------") print("Weather Starts for - {} || {}".format(location.upper(), date_time)) print("-------------------------------------------------------------------") print("Current Temperature is : { :.2f} deg C".format(temp_city)) print("Current Weather Description :- ", wether_des) print("Current Humidity :- ", humdt , '%') print("Current Wind Speed :- ", wind_spd, 'kmph') f = open("api_data", 'w')

Stargazers