python 学习_第二模块 configparser 模块
import configparser conf = configparser.ConfigParser() # 实例化 conf.sections() # 调用sections方法 conf.read('test.ini') # 查看 print(conf['topsecret.server.com']['port']) # 添加 section sec = conf.add_section('wupeiqi') conf.write(open('test.ini', "w")) # # # # # # # 添加值 conf.set("wupeiqi", "db_pass", "zhaowei") conf.set("wupeiqi",'k1','11111') conf.write(open("test.ini", "w")) # # # #删除 conf.remove_option('wupeiqi','db_pass') conf.write(open('test.ini','w')) # 删除 section conf.remove_section("wupeiqi") conf.write(open('test.ini', "w"))
posted on 2019-03-22 13:49 augustyang 阅读(98) 评论(0) 编辑 收藏 举报