L
Lialie
Hello,all
I found it easy to read configures from a config file.
But how can I set a special value to an item or write it into the
original file?
I have tried this:
import ConfigParser
config = ConfigParser.ConfigParser()
config.read('a.conf')
config.get('Main', 'Something') # That is OK.
config.set('Main', 'Something', '2') # without any fault
#fp = open('a.conf') # can not be done, raise Error
#fp = open('a.conf', 'a') # Something set to 2, but it copies the all items
#config.write(fp)
# How can I do it?
I found it easy to read configures from a config file.
But how can I set a special value to an item or write it into the
original file?
I have tried this:
import ConfigParser
config = ConfigParser.ConfigParser()
config.read('a.conf')
config.get('Main', 'Something') # That is OK.
config.set('Main', 'Something', '2') # without any fault
#fp = open('a.conf') # can not be done, raise Error
#fp = open('a.conf', 'a') # Something set to 2, but it copies the all items
#config.write(fp)
# How can I do it?