import configparser
### 加载配置文件 holo_config = configparser.ConfigParser() base_path=os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if 'tmp' in base_path: base_path = '/tmp/src/app' config_path=f'{base_path}/config2.properties' holo_config.read(config_path) print('-----path---->',config_path) logging.info(config_path) ### 读取配置文件 host=holo_config.get("Hologress","host"), port=holo_config.get("Hologress","port"), dbname=holo_config.get("Hologress","dbname"), user=holo_config.get("Hologress","user"), password=holo_config.get("Hologress","password")
config2.properties:
[Hologress] host=192.168.1.1 port=8080 dbname=your_db_name user=root password=123123 mysql_config=mysql+pymysql://root:123123@xxx.com:3308/data_big_db