-
-
Save parzibyte/290315e2adecbcdf011ac214381a0fc8 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
{ | |
"dbname": "tienda", | |
"user": "postgres", | |
"password": "hunter2", | |
"host": "localhost", | |
"port": 5432 | |
} |
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
""" | |
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