python连接mysql,报错:configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%Sgmfc'

运行代码时抛出错误: configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%Sgmfc'

 

判断原因:在读取配置时,配置文件中存在%这个一类的特殊字符

 

解决方案:

   在读取配置中将 self.config = configparser.ConfigParser()方法,换成:self.config = configparser.RawConfigParser()

  

  完美解决!!

posted @ 2022-11-03 15:43  麥女孩的小火柴  阅读(419)  评论(0)    收藏  举报