使用配置檔案裝載一些條件,以及一些對資料庫進行操作的語句等;作為對資料處理的一些外接條件。
類似於讀取字典形式import configparser
config_file = r"{}".format(interdoc['conf'])
config = configparser.configparser()
config.read(config_file)
all_cond = config.sections()#讀取檔案中所有的字段
cond_count = 0
例子:config.get('dep_cond1', 'branchcode')獲取dep_cond1中的branchcode的值***xx
[dep_cond1]
branchcode = ***xx
legal_entity= x'x'x'x
branch_notin_list = ***xx
reason_desc = ***xx
[dep_cond2]
branchcode = ***xx
legal_entity= aro
branch_notin_list = ***xx
reason_desc = ***xx
[dep_cond3]
branchcode = ***xx
legal_entity= gks
branch_notin_list = ***xx
reason_desc = ******x
python讀取 ini 配置檔案
在詳解python讀取ini檔案之前,我們先說明乙個ini檔案的組成 乙個ini檔案是由多個section組成,每個section中以key vlaue形式儲存資料 然後我們來使用python讀取ini檔案中的資料 1導包 導包import configparser config configpar...
Python讀取ini配置檔案
mysql conf 1 在ini配置檔案中,中的值被稱為section host 127.0.0.1 3 乙個section下的鍵值對被稱為option port 3306 4 同乙個section下也可以存在多個option,也就是多個鍵值對的配置項 username root password...
python 讀取 ini 配置檔案
關於讀取配置檔案的想法 主要是因為程式裡面通過改變變數值 達到不同的目的 如果寫死 變成常量 如果下次領導說換乙個玩法 還得去改 再重新編譯一次 開發過程中發現較關鍵的變數 最好是把它配置化 當然如果你來了 肯定也是為此 進入正題 config.ini test addr test2 addr 寫乙...