18 lines
438 B
Python
18 lines
438 B
Python
# -*- coding: utf-8 -*-
|
|
import os
|
|
from configparser import ConfigParser
|
|
|
|
ENVIRONMENT=os.getenv("ENVIRONMENT", "test")
|
|
print(f"当前环境为:{ENVIRONMENT}")
|
|
conf = ConfigParser()
|
|
path=os.path.dirname(__file__).replace("\\utils", "")
|
|
conf.read(f"{path}\\config\\config.ini")
|
|
config = conf[ENVIRONMENT]
|
|
# 遍历conf
|
|
for k, v in config.items():
|
|
config[k] = v.strip()
|
|
os.environ[k] = v.strip()
|
|
|
|
print(f"加载配置文件完成")
|
|
|