Closed littlealili closed 3 years ago
def read_config(): config = cp.ConfigParser() cur_path = os.path.abspath(os.path.join(os.path.dirname(file), "..")) config.read(os.path.join(cur_path, 'config.ini')) host = socket.gethostname() return config[host]
I used that config to use different configs in different servers. Feel free to omit that part if you dont need it.
When return config[host], there is an error :Exception has occurred: KeyError 'pc008'. Why?
def read_config(): config = cp.ConfigParser() cur_path = os.path.abspath(os.path.join(os.path.dirname(file), "..")) config.read(os.path.join(cur_path, 'config.ini')) host = socket.gethostname() return config[host]