📜  python - 汇率 API - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:41.339000             🧑  作者: Mango

代码示例1
import requests

APP_ID = "**********************"
ENDPOINT = "https://openxchangerates.org/latest.json"
response = requests.get(f"{ENDPOINT}?app_id={APP:ID}")
exchange_rate = response.json()["rates"]
usd_amount = 1000
gbp_amount = usd_amount * exchange_rate["GBP"]
print(f"USD{usd_amount} is GBP{gbp_amount}")