发布时间:2022-12-20 09:34:21 人气:99 作者:多测师
python中ConfigParser是什么
1、将数据库连接参数的配置写入配置文件,然后使用ConfigParser进行管理。
在连接数据库时,我们可以读取配置参数,然后生成连接字符串。
2、ConfigParser本身就提供了生成连接字符串的功能。
实例
$cat db.conf
[DEFAULT]
conn_str = %(dbn)s://(%user)s:%(pw)s@%(host)s:%(port)s/%(db)s
dbn = mysql
user = root
pw = root
host = localhost
port = 3306
db = test
以上就是python中ConfigParser的介绍,希望对大家有所帮助。更多Python学习指路:请关注多测师。https://www.e70w.com/xwzx/