Skip to content

Instantly share code, notes, and snippets.

@baobao
Last active December 7, 2018 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baobao/3d6f52ac61a9a76204936835ffca8bbb to your computer and use it in GitHub Desktop.
Save baobao/3d6f52ac61a9a76204936835ffca8bbb to your computer and use it in GitHub Desktop.
# 引数に都市名の入力が必要
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment