码迷,mamicode.com
首页 > 其他好文 > 详细

configparser读写配置文件

时间:2017-10-29 17:36:10      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:12px   读取   str   config   value   配置文件   一个   span   font   

1.读取配置文件

-read(filename) 直接读取ini文件内容
-sections() 得到所有的section,并以列表的形式返回
-options(section) 得到该section的所有option
-items(section) 得到该section的所有键值对
-get(section,option) 得到section中option的值,返回为string类型
-getint(section,option) 得到section中option的值,返回为int类型
 

2写入配置文件

-add_section(section) 添加一个新的section
-set( section, option, value) 对section中的option进行设置
  需要调用write将内容写入配置文件。

configparser读写配置文件

标签:12px   读取   str   config   value   配置文件   一个   span   font   

原文地址:http://www.cnblogs.com/chengguxian/p/7750406.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!