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))
|