Change value in ini file using ConfigParser Python

后端 未结 3 1444
我在风中等你
我在风中等你 2021-02-05 14:20

So, I have this settings.ini :

[SETTINGS]

value = 1

And this python script

from ConfigParser import SafeConfigParser

parser =         


        
3条回答
  •  误落风尘
    2021-02-05 15:26

    As from the examples of the documentation:

    https://docs.python.org/2/library/configparser.html

    parser.set('SETTINGS', 'value', '15')
    
    
    # Writing our configuration file to 'example.ini'
    with open('example.ini', 'wb') as configfile:
        parser.write(configfile)
    

提交回复
热议问题