1、首先安装常用的组件 : configobj模块

pip install configobj

 

2、然后引用即可

from configobj import ConfigObj
#注意大小写

 

3、使用举例

test.ini文件为如下关键词

[test_section]
test_param = test_value

 

那么python代码如下:

from configobj import ConfigObj  

config = ConfigObj("test.ini",encoding='UTF8')  

# 读配置文件  
print config['test_section']  
print config['test_section']['test_param '] 

 

相关文章:

  • 2022-02-04
  • 2021-08-30
  • 2021-09-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2022-12-23
相关资源
相似解决方案