Created
January 18, 2021 03:44
-
-
Save RomainL972/4659e7eccc0a7e67fff85113e3d74043 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python3 | |
import requests | |
from dateutil.parser import parse | |
def main(): | |
fromcur = input("From currency : ") | |
tocur = input("To currency : ") | |
amount = float(input("Amount : ")) | |
date = input("Date : ") | |
if not date: | |
date = "latest" | |
res = requests.get("https://api.exchangeratesapi.io/" + date + "?base=" + fromcur + "&symbols=" + tocur) | |
data = res.json() | |
rate = data["rates"][tocur] | |
print("{} {} = {} {}".format(amount, fromcur, amount * rate, tocur)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment