How to read a config file without keys in python -
so have created config file & need read data it.
the config file looks like:-
[sport] cricket soccer tennis where sport section name & rest keys.
i able read file without values using allow_no_value=true option.
my problem need print 1st record in sport section & store in variable.
my code till now:-
import configparser config = configparser.configparser(allow_no_value=true) config.read('sport.ini') val1 = config.get('sport') print val1 it shows me error as:-
val1 = config.get('sport') typeerror: get() takes @ least 3 arguments (2 given) kindly let me know how 1st record config file & store in variable.
you have pass key also
>>>print(config.get('sport', 'cricket')) none or view key value pairs
>>>config.items('s') [('cricket', none), ('soccer', none), ('tennis', none)]
Comments
Post a Comment