python读取ini文件时,特殊字符的读取

前言:

使用python在读取配置文件时,由于配置文件中存在特殊字符,读取时出现了以下错误:

1 configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%sbc09'

错误代码:

1 config=configparser.ConfigParser()

解决方案:

使用 RawConfigParser()方法进行读取即可,代码如下:

1 config=configparser.RawConfigParser()

 

    原文作者:何乐而不为
    原文地址: https://www.cnblogs.com/lw-whatever/p/11385971.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞