Python加载配置文件

  • 代码
import ConfigParser

try:
    cf = ConfigParser.ConfigParser()
    cf.read('conf.ini')
    workplace = cf.get('product', 'workplace')
except Exception:
    pass
  • 配置文件conf.ini
[product]
workplace = /data/app/product

[test]
workplace = /data/app/test

你可能感兴趣的:(Python加载配置文件)