Skip to content

Instantly share code, notes, and snippets.

@Bill-Park
Last active July 7, 2019 07:14
Show Gist options
  • Save Bill-Park/f8a46d094fa83f5fc025c699d95a95c1 to your computer and use it in GitHub Desktop.
Save Bill-Park/f8a46d094fa83f5fc025c699d95a95c1 to your computer and use it in GitHub Desktop.
import requests
import json
api_key = "dd40631e0b2c53fdc84e1dffd1da95f6"
url = "http://api.openweathermap.org/data/2.5/weather?q=Seoul&appid={key}".format(key=api_key)
def main() :
res = requests.get(url)
res_json = json.loads(res.text)
temperature = round(res_json["main"]["temp"] - 273, 1)
humidity = round(res_json["main"]["humidity"])
return temperature, humidity
if __name__ == "__main__" :
temp, humi = main()
print(temp)
print(humi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment