最近在在看别人代码的时候发现有人用了config这个库来保存一些超参数,超参数的设置在深度学习中是很是重要了。通常的config 库能够直接经过pip install config 安装python
废话很少说,直接上一个官网上的简单样例;学习
先建立个配置文件simple.cfg,内容以下:this
# The message to print (this is a comment) message: 'Hello, world!'
#符号是注释做用orm
每行用 : 符号做为分隔符blog
from config import Config # You can pass any file-like object; if it has a name attribute, # that name is used when file format error messages are printed f = file('simple.cfg') cfg = Config(f) print cfg.message
值的话通常是支持字符串,bool行的True和False,以及数字ip