configparser模块

import configparser

conf = configparser.ConfigParser()
#
# print(conf.sections())

conf.read("conf.ini")

print(conf.sections())


>>>['bitbucket.org', 'topsecret.server.com']

print(conf.default_section)
>>>DEFAULT #重复的点,都可以写在default里
增删改查

conf.remove_section("group1")

conf.add_section("group3")
conf['group3']['name'] = "Alex Li"
conf['group3']['age'] = "22"

  

猜你喜欢

转载自www.cnblogs.com/yelublue/p/9029509.html