RawConfigParser 与 ConfigParser ——Python的配件文件读取模块

一般情况都是使用ConfigParser这个方法但是当我们配置中有%(filename)s这种格式的配置的时候可能会出现以下问题:

configparser.InterpolationMissingOptionError: Bad value substitution: option 'output_fmt' in section 'output' contains an interpolation key 'asctime' which is not a valid option name.

Raw value: '"%(asctime)s-%(levelname)s-%(filename)s-%(name)s-日志信息:%(message)s"'

解决办法就是:

将configparser方法换成了RawConfigParser方法上面的问题就pass掉了。

猜你喜欢

转载自www.cnblogs.com/rightlight/p/10571083.html