# -*- coding: utf-8 -*- # @Author: Gree # @Date: 2021-05-29 14:49:12 # @Last Modified by: Gree # @Last Modified time: 2021-05-29 15:02:21 import configparser import os class ReadConfig: def __init__(self): """ 1. 初始化变量 """ # 获取 self.dirPath self.dirPath = os.path.split(os.path.realpath(__file__))[0] # 获取 self.filePath self.filePath = os.path.join(self.dirPath, "stopWord.conf") # 生成 cf 对象 self.cf = configparser.ConfigParser() def readConfig(self): """ 1. 读取配置文件 """ # 读取 stopWord.conf 配置文件 self.cf.read(self.filePath) # 获取 stopWordList stopWordList = self.cf["stop_word"]["stop_word"].split(",") # 返回 stopWordList return stopWordList