加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

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

发布时间:2020-12-20 10:55:19 所属栏目:Python 来源:网络整理
导读:前言: 使用python在读取配置文件时,由于配置文件中存在特殊字符,读取时出现了以下错误: 1 configparser.InterpolationSyntaxError: ‘ % ‘ must be followed by ‘ % ‘ or ‘ ( ‘ ,found: ‘ %sbc09 ‘ 错误代码: 1 config=configparser.ConfigParse

前言:

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

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

错误代码:

1 config=configparser.ConfigParser()

解决方案:

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

1 config=configparser.RawConfigParser()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读