Cómo saber el precio del dolar del dia

in #pyhon6 years ago


Hola chicos

Hoy quiero publicar un código en Python que hace poco tuve la necesidad de implementar y es el siguiente:

que tal si quieres saber el precio del dolar del dia en tu moneda local?
Para eso vamos a usar el siguiente código:


import requests
#Consultamos la api de la trm del dia
valor_dolar_colombia = requests.get("https://www.datos.gov.co/resource/g3ab-sax9.json?$order=vigenciadesde DESC&$limit=1")
valor_dolar_colombia = valor_dolar_colombia.json()
valor_dolar_colombia = valor_dolar_colombia[0]['valor']
valor_dolar_colombia = float(valor_dolar_colombia) 
print '\n'
print "Valor del dolar hoy es: ", format(valor_dolar_colombia,",.2f"), "pesos colombianos" +'\n'

Espero haber podio aportar algo
No se te olvide preguntar si tienes alguna duda y Siguirme para que no te pierdas futuras públicaciones.

Saludos y hasta la próxima.

Sort:  

Este Post ha recibido un Upvote desde la cuenta del King: @dineroconopcion, El cual es un Grupo de Soporte mantenido por 5 personas mas que quieren ayudarte a llegar hacer un Top Autor En Steemit sin tener que invertir en Steem Power. Te Gustaria Ser Parte De Este Projecto?

This Post has been Upvote from the King's Account: @dineroconopcion, It's a Support Group by 5 other people that want to help you be a Top Steemit Author without having to invest into Steem Power. Would You Like To Be Part of this Project?