일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- numpy
- PostgreSQL
- Paper
- Laravel
- list
- KAKAO
- judge
- Container
- pandas
- Python
- file
- Converting
- git
- DB
- evaluation
- AI
- enV
- LLM
- format
- GitLab
- Windows
- pytorch
- docker
- Mac
- Package
- TORCH
- Linux
- Database
- Flask
- CUDA
Archives
- Today
- Total
Daily Develope
[Python] config 환경설정 관리 및 사용 본문
INI 확장자 예시
ㅇ 환경설정 파일 (conf/config.ini)
[mysql]
user = root
password = mypasswd
host = 127.0.0.1
port = 3306
database = mydb
table = mytable
ㅇ 사용 예시
1) parser 정의 (conf/cfgParser.py)
import configparser
import os
def get(section, name):
value = None
config = configparser.ConfigParser(allow_no_value=True)
config.read('config.ini')
value = config.get(section, name)
return value
2) 사용 (main.py)
import conf.cfgParser as cp
user = cp.get('mysql', 'user')
print(user)
yml, json, xml, etc...
'Develope > Python' 카테고리의 다른 글
[Python] Numpy 넘파이 함수 정리 (0) | 2022.04.04 |
---|---|
[Python] MFCC 구현 (0) | 2022.04.04 |
[Python] PCM 음성파일 파형 출력 (with pyplot) (0) | 2022.02.15 |
[Python] PCM 파일 통합 및 WAV로 변환 (0) | 2022.02.15 |
[Python] 매칭 (문자열 / 리스트 / 정규식) (0) | 2022.01.15 |
Comments