class CaseSConfigParser(ConfigParser):
# 重写optionxform解决options大小写不敏感
"""
To solve case problem when using the function options()
"""
def __init__(self, ):
ConfigParser.__init__(self, defaults=None)
def optionxform(self, optionstr):
return optionstr
def config():
cf = CaseSConfigParser()
cf.read('/home/razerware/configscript/config.conf')
section = 'docker'
#写配置文件
config.add_section("docker1")
config.set("docker1", "pages", 250)
#读配置文件
global INFO_NUM
INFO_NUM = cf.getint(section, 'info_num')#读数字
global APP_DIR
APP_DIR = cf.get(section, 'app_dir')#读字符串
[docker]
#how many info showed in table monitor
info_num = 5
#worker number of monitor.py
process_num = 11
#port config
port_start= 10000
原文地址:http://blog.csdn.net/l6807718/article/details/53301436