凌的博客

您现在的位置是: 首页 > 学无止境 > python > 

python

Python 使用 configparser

2020-02-29 python 774

1.jpg

from configparser import ConfigParser

cf = ConfigParser()
conf_file = "./data/conf.ini"
cf.read(conf_file)
cf.add_section("settings")
cf.set("settings","username","manager")
cf.set("settings","password","123456")
with open(conf_file,"w",encoding="utf-8") as f:
    cf.write(f)


文章评论

0条评论