配置文件
配置文件常常会分为本地开发以及生产部署两种,一种简洁的配置如下:
import configparser
config = configparser.ConfigParser()
default = os.path.join(os.path.dirname(__file__), './default.ini')
production = os.path.join(os.path.dirname(__file__), './production.ini')
cfg = [default]
if is_production():
cfg.append(production)
config.read(cfg, 'utf-8')
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
编辑此页 (opens new window)
更新于: 2019-06-12 10:58