This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author quanyechavshuo
Recipients quanyechavshuo
Date 2017-06-26.09:48:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1498470490.58.0.585332868378.issue30760@psf.upfronthosting.co.za>
In-reply-to
Content
Hello,I was using configparser module in python3.6,but find it works not good when I try to write '%' to my config file,below is my func:

def update_config_file_key_value(file, section, key_name, key_value):
    # 通过configparser模块的调用更新配置文件
    # section是[]里面的值
    if os.path.exists(file) == False:
        os.system("touch %s" % file)
    import configparser
    config = configparser.ConfigParser()
    config.read(file)
    sectionList = config.sections()
    if section not in sectionList:
        config.add_section(section)
    config.set(section, key_name, str(key_value))
    with open(file, 'w') as f:
        config.write(f)

When I use it as:
update_config_file_key_value('config.ini','default','cookie',"123")
it works well,but below not ok:
update_config_file_key_value('config.ini','default','cookie',"%123")
and below not ok:
update_config_file_key_value('config.ini','default','cookie',"123%")
and below not ok:
update_config_file_key_value('config.ini','default','cookie',"12%3")

That's to say,configparser can not write '%' to config file.
History
Date User Action Args
2017-06-26 09:48:10quanyechavshuosetrecipients: + quanyechavshuo
2017-06-26 09:48:10quanyechavshuosetmessageid: <1498470490.58.0.585332868378.issue30760@psf.upfronthosting.co.za>
2017-06-26 09:48:10quanyechavshuolinkissue30760 messages
2017-06-26 09:48:10quanyechavshuocreate