ConfigParser跨目录读取配置文件,报错如下:
configparser.NoSectionError: No section: 'mysql'
使用绝对路径 import os
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(path) cp = ConfigParser() cp.read(path+"/config/db.conf")
ConfigParser跨目录读取配置文件,报错如下:
configparser.NoSectionError: No section: 'mysql'
使用绝对路径 import os
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(path) cp = ConfigParser() cp.read(path+"/config/db.conf")