Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Last active April 8, 2019 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/290315e2adecbcdf011ac214381a0fc8 to your computer and use it in GitHub Desktop.
Save parzibyte/290315e2adecbcdf011ac214381a0fc8 to your computer and use it in GitHub Desktop.
{
"dbname": "tienda",
"user": "postgres",
"password": "hunter2",
"host": "localhost",
"port": 5432
}
"""
Ejemplo de parseo de un archivo JSON a un tipo
nativo en Python 3
@author parzibyte
"""
import json
with open("credenciales.json") as archivo_credenciales:
credenciales = json.load(archivo_credenciales)
# Usa get o diccionario["indice"]
nombre_bd = credenciales.get("dbname")
print(nombre_bd)
puerto = credenciales.get("port")
print(puerto)
password = credenciales.get("password")
print(password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment