Last active
July 7, 2019 07:14
-
-
Save Bill-Park/f8a46d094fa83f5fc025c699d95a95c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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