一、实验环境
1.Windows10x64
2.anaconda4.6.9 + python3.7.1(anaconda集成,不需单独安装)
二、代码示例
# -*- coding: utf-8 -*-
import os
from configparser import ConfigParser, NoSectionError
debug = False
def debug_print(str):
if debug:
print(str)
class GetConfig(ConfigParser):
def __init__(self, defaults=None):
"""
初始化函数
:param defaults:
"""
ConfigParser.__init__(self, defaults=None)
def optionxform(self, optionstr):
"""
解决ConfigParser将键值对强制转换为小写问题
:param optionstr:
:return:
"""
return optionstr
def open_file(self, file_name):
"""
打开config文件夹
:param file_name: config文件路径
:return:
"""
if os.path.exists(file_n