configparser.NoSectionError: No section: '****'解决办法

时间:2020-11-19 14:16:20   收藏:0   阅读:757

解决方案:
config.read()读取绝对路径

import configparser
import os, sys

parent_dir = os.path.dirname(os.path.abspath(__file__))

config = configparser.ConfigParser()
config.read(parent_dir + "/main.conf")   #读取配置文件采用绝对路径

原文:https://www.cnblogs.com/ojbk6943/p/14004481.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!