0
I’m practicing learning Apis with HG Finance , but when I filter the information through a FOR , I see that presents an error called KeyError: nome da moeda
, But the code runs the same way, I’d like to understand how to get the exact information out of a json with multiple arrays and how to get that error out. follows my code below:
import requests
arquivo = open('C:/Users/Usuario/PycharmProjects/Aprendizado/ pass.txt', mode='r')
senha =arquivo.read()
requests= requests.get("https://api.hgbrasil.com/finance/quotations?key={}".format(senha))
dados = requests.json()
moeda= input("Moeda Desejada: ")
for x in dados['results'].values():
for z in x[moeda].items():
print(z)