# -*- coding: utf-8 -*-
# @Time :2021/3/28 21:08
# @Author :wang-kai
# @tel :15313929271
# @File :配置文件.py
from configparser import ConfigParser
'''读取正数 getint(),getboolean(),'''
class ReadConfig:
def __init__(self, filename):
self.cf = ConfigParser() # 创建对象
self.cf.read(filename, encoding='utf-8') # 打开文件
"""读取数据"""
def get_data(self, section, option):
value = self.cf.get(section, option)
return eval(value)
if __name__ == '__main__':
data = ReadConfig('peizhi.conf').get_data('test_01', 'test')
print(data)