Read all the contents in ini file into dictionary with Python
问题 Normally, I code as follows for getting a particular item in a variable as follows try: config = ConfigParser.ConfigParser() config.read(self.iniPathName) except ConfigParser.MissingSectionHeaderError, e: raise WrongIniFormatError(`e`) try: self.makeDB = config.get("DB","makeDB") except ConfigParser.NoOptionError: self.makeDB = 0 Is there any way to read all the contents in a python dictionary? For example [A] x=1 y=2 z=3 [B] x=1 y=2 z=3 is written into val["A"]["x"] = 1 ... val["B"]["z"] = 3