27 lines
		
	
	
		
			754 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			754 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| import json, os
 | |
| from utils.Log import Log
 | |
| 
 | |
| current_directory = os.path.dirname(os.path.abspath(__file__))
 | |
| root_path = os.path.abspath(os.path.dirname(current_directory) + os.path.sep + ".")
 | |
| # log.info(str(root_path))
 | |
| project_name = root_path.split(os.path.sep)[-1]
 | |
| # log.info(str(project_name))
 | |
| project_root_path = os.path.abspath(os.path.dirname(__file__)).split(project_name)[0] + project_name
 | |
| 
 | |
| 
 | |
| log = Log()
 | |
| 
 | |
| 
 | |
| def loadconfig(config_key):
 | |
|     json_file = project_root_path + "/config/config.json"
 | |
|     with open(json_file) as f:
 | |
|         cfg = json.load(f)[config_key]
 | |
|     log.info(' 读取配置:' + config_key)
 | |
|     log.info(cfg)
 | |
|     return cfg
 | |
| 
 | |
| 
 | |
| if __name__ == '__main__':
 | |
|     yz_mysql_config = loadconfig('yz_mysql')
 | |
|     print(yz_mysql_config['host'])
 | 
