=== 文本键值对配置文件 === config.conf [global] ip = 123 ; 感叹号之后的被注释 #name =345 #开头的被注释 import ConfigParser config = ConfigParser.ConfigParser() config.readfp(open("config.conf","rb")) print config.get("global","ip") === python 字典类型配置文件 === config.py database={} database['host']='10.0.2.3' database['name']='test' from config import database print database['hostname']