신호생성 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.
 
 

37 lines
748 B

import os
import sys
if '__file__' in globals():
script_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(script_dir)
# json 예시
import json
with open('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('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)
from pathlib import Path
script_dir = os.path.dirname(os.path.abspath(__file__))
print(script_dir)
print(Path(script_dir))