BluePen BluePen
  • Jenkins
  • OS
  • 算法
随笔
分类
标签
归档
关于
留言板
GitHub (opens new window)

Alex

一个好人
  • Jenkins
  • OS
  • 算法
随笔
分类
标签
归档
关于
留言板
GitHub (opens new window)
  • 命令行参数解析
  • 配置文件
  • 日志打印
  • 执行系统命令
  • Python
Alex
2019-06-12

配置文件

配置文件常常会分为本地开发以及生产部署两种,一种简洁的配置如下:

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
编辑此页 (opens new window)
更新于: 2019-06-12 10:58
命令行参数解析
日志打印

← 命令行参数解析 日志打印→

Copyright © 2019-2022 | yxxy | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式