python基础知识~配置文件模块

一 配置文件模块
   import ConfigParser ->导入模块
  conf = ConfigParser.ConfigParser() ->初始化类
二 系统函数
  conf.read('*.conf')->读取配置文件
  conf.sections()->获取section列表
  conf.get("section1", "key")(getint) ->根据section+key获取values值
  conf.items('sections')->根据section获取键值列表
  conf.options("db1")->根据section获取键列表
三 配置文件格式
  [db1] ->section
  key1=value1
  key2=value2
  key3=value3
  key叫option,此处key = value整体叫作items

猜你喜欢

转载自www.cnblogs.com/danhuangpai/p/9636887.html