新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python中ConfigParser是什么
1、將數(shù)據(jù)庫連接參數(shù)的配置寫入配置文件,然后使用ConfigParser進行管理。

在連接數(shù)據(jù)庫時,我們可以讀取配置參數(shù),然后生成連接字符串。
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學(xué)習(xí)指路:創(chuàng)新互聯(lián)python教程
本文教程操作環(huán)境:windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。
本文標(biāo)題:創(chuàng)新互聯(lián)Python教程:python中ConfigParser是什么
本文地址:http://www.dlmjj.cn/article/djphijd.html


咨詢
建站咨詢
