Python 读取配置文件

1、配置文件db_config.ini

 

 

2、Python读取配置文件

import configparser

'''
读取配置文件
'''
#创建一个管理对象
conf = configparser.ConfigParser()

#配置文件导入管理对象,配置文件内容加载到内存中
conf.read('db_config.ini')

#获取指定selection 的 option 值
user = conf.get("DATABASE1","user")
port = conf.get("DATABASE1","port")
print(user,port)

 

posted @ 2018-02-26 14:55  我是旺旺  阅读(196)  评论(0编辑  收藏  举报