利用configparse库读取配置文件。
使用配置文件装载一些条件,以及一些对数据库进行操作的语句等;作为对数据处理的一些外置条件。
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的值xxxxx
[Dep_cond1]
branchcode = xxxxx
legal_entity= x'x'x'x
branch_notin_list = xxxxx
reason_desc = xxxxx
[Dep_cond2]
branchcode = xxxxx
legal_entity= ARO
branch_notin_list = xxxxx
reason_desc = xxxxx
[Dep_cond3]
branchcode = xxxxx
legal_entity= GKS
branch_notin_list = xxxxx
reason_desc = xxxxxxx