https://openexchangerates.org/から特定の日付から通貨データを収集し、それを辞書として返す関数を作成しようとしています。YYYY-MM-DD と書かれている URL に日付を挿入する方法と、それを Python に取り込む方法に少し固執しています。
どんな助けでも大歓迎です
これまでに持っている私のコードは次のとおりです。
def _fetch_exrates(date):
import json
import urllib.request
f = urllib.request.urlopen('http://openexchangerates.org/api/historical/YYYY-MM-DD.json?app_id=188bd7b8d2634e4cb0602ab5b3c223e7')
charset = f.info().get_param('charset', 'utf8')
data = f.read()
decoded = json.loads(data.decode(charset))
print(json.dumps(decoded, indent=4))
import datetime
print('Please but the year in the form of YYYY and the month as MM and day as DD')
a = int(input('choose a year :',))
b = int(input('choose a month :',))
c = int(input('choose a day :',))
date = datetime.date(a,b,c)
print(date)