baobao
11/13/2017 - 5:28 PM

openweathermap

# 引数に都市名の入力が必要
import requests
import json
import sys

API_KEY = "APIキー"
api = "http://api.openweathermap.org/data/2.5/weather?q={city}&APPID={key}"

city_name = sys.argv[1]
url = api.format(city = city_name, key = API_KEY)
print(url)
response = requests.get(url)
data = json.loads(response.text)
print(data)