# -*- coding: UTF-8 -*- """ @Project :onestar @File :ConfigeHandle.py @Contact:https://blog.csdn.net/songlh1234/article/details/83316468 @Author :SHJ @Date :2021/11/23 16:57 @Version :1.0.0 """ import os import configparser class Config: """读写初始化配置文件""" def __init__(self): pass @staticmethod def get(para_name, option='config', config_name = 'config.ini'): config = configparser.ConfigParser() config_path = os.path.join(os.getcwd(), config_name) config.read(config_path, encoding='utf-8') config.sections() exe_name = config.get(option, para_name) return exe_name if __name__ == '__main__': # c = Config() # a = c.get('exe_name') # b = bool(c.get('debug')) # d = int(c.get('cover_threshold')) # f = float(c.get('ndvi_threshold')) print('done')