신호생성 repo (24. 1. 5 ~).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

34 lines
788 B

import os
import sys
from pathlib import Path
if __name__ == '__main__':
# 현재 .py이 위치한 디렉토리
script_dir = os.path.dirname(os.path.abspath(__file__))
script_dir = Path(script_dir)
# json 예시
import json
with open(script_dir / 'config.json', 'r') as config_file:
config = json.load(config_file)
print('==== json 예시 ====')
print(config)
print()
# ini 예시
from configparser import ConfigParser
config = ConfigParser()
config.read(script_dir / 'config.ini')
user = config['DEFAULT']['User']
password = config['DEFAULT']['Password']
host = config['MySQL']['Host']
database = config['MySQL']['Database']
print('==== ini 예시 ====')
print(user, password, host, database)