python - ConfigParser getting value from INI file with section and subsection as shown below -


i have following type of ini file

[section1][subsection1] port=989 [section1][subsection2] somethign=somethign  

i using configparser of python parse ini file not able figure out on how data above kinda ini file.

the below code getting value when ini file

[section1] port=908 [section2] ss=ss  config = configparser.rawconfigparser() config.read(ini_file) mip =  config.get('section1','port') 

please don't suggest me change ini file format :)

thank you

it appears configparser ignores subsections. if absolutely need subsections, may want try alternative parsers such configobj (pypi, tutorial)

and here answer older question: https://stackoverflow.com/a/3008051/49412


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -