3
How can I transform data from a file .ini
in a dict
in Python?
Is there any way to do this in Python
?
[database]
host = localhost
password = sabe_nada_de_python
port = 3306
3
How can I transform data from a file .ini
in a dict
in Python?
Is there any way to do this in Python
?
[database]
host = localhost
password = sabe_nada_de_python
port = 3306
4
Yes, using configparser
:
import configparser
import os
configuracao = configparser.ConfigParser()
configuracao.read(os.path.join(os.getcwd(), "meuarquivo.ini"))
host = configuracao["database"]["host"]
password = configuracao["database"]["password"]
port = configuracao["database"]["port"]
Browser other questions tagged python ini
You are not signed in. Login or sign up in order to post.
+1. good answer. I thought it was native but need to install.
– Wallace Maxters