Oct-31-2018, 10:58 PM
Hi,
When running the below code, I get an error message but I don't understand it. I appreciate some insights.
TIA
data.ini
When running the below code, I get an error message but I don't understand it. I appreciate some insights.
TIA
data.ini
[settings] volume = "99" tz = "2" first-1 = "a" first-2 = "b" first-3 = "c"readini.py
try: from configparser import ConfigParser except ImportError: from ConfigParser import ConfigParser # ver. < 3.0 # instantiate config = ConfigParser() # parse existing file config.read('data.ini') def readInstance(instance): if instance in config.sections(): #checks if the given instance actually exists in the config file volume = config.getint[instance]["volume"].strip('\"') #read the specific config data and then convert it into an integer tz = config.getint[instance]["tz"].strip('\"') # repeat process for ending print volume print tz readInstance("settings") #print config.getint('settings', 'volume').strip('\"')error msg.
Traceback (most recent call last): File "readini.py", line 24, in <module> readInstance("settings") File "readini.py", line 14, in readInstance volume = config.getint[instance]["volume"].strip('\"') #read the specific config data and then convert it into an integer TypeError: 'instancemethod' object has no attribute '__getitem__'