ConfigParser.InterpolationSyntaxError: ‘%‘ must be followed by ‘%‘ or ‘(‘, found: “%‘“
Python使用configparser读取配置文件(config.ini)过程中,报异常信息:ConfigParser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: "%&'"
目录
1、配置文件
2、核心代码
3、 问题解决
1、配置文件
# 定义cmd分组
[cmd]
startServer=adb start-server
2、核心代码
import configparser# 实例化configParser对象
config = configparser.ConfigParser()# -get(section,option)得到section中option的值,返回为string类型
print(config.get('cmd', 'startserver'))
3、 问题解决
将configparser.ConfigParser()替换成:configparser.RawConfigParser() 即可解决这个问题。
import configparser# 实例化configParser对象
config = configparser.RawConfigParser()# -get(section,option)得到section中option的值,返回为string类型
print(config.get('cmd', 'startserver'))
ConfigParser.InterpolationSyntaxError: ‘%‘ must be followed by ‘%‘ or ‘(‘, found: “%‘“相关推荐
- ConfigParser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: %' 解决方案
前言 在写python程序读取配置文件的时候,遇到了一个错误,记录下解决方案. 错误如下: ConfigParser.InterpolationSyntaxError: '%' must be fol ...
- 十四、报错:configparser.InterpolationSyntaxError: ‘%‘ must be followed by ‘%‘ or ‘(‘, found: “%)‘] 的解决
报错内容: Failed to import test module: app.BusinessProcess.testLendRequestProcess.testPrivateOwner.test ...
- ConfigParser.InterpolationSyntaxError: ‘%‘ must be followed by ‘%‘ or ‘(‘, found: “%‘“ 解决方案
解决方案 换一种方式进行读取配置文件 原本代码:cf= configparser.ConfigParser() 替换成: cf = configparser.RawConfigParser() 参考: ...
- Python3 配置文件(configparser)(转载)
本文由 Luzhuo 编写,转发请保留该信息. 原文: http://blog.csdn.net/rozol/article/details/72793304 以下代码以Python3.6.1为例 ...
- Python拓展12(使配置文件生效ConfigParser模块)
1.简介 ConfigParser模块在python3中修改为configparser.这个模块定义了一个ConfigParser类,该类的作用是使用配置文件生效,配置文件的格式和windows的IN ...
- python config_python config的用法
简介 ConfigParser模块在python3中修改为configparser.这个模块定义了一个ConfigParser类,该类的作用是使用配置文件生效,配置文件的格式和windows的INI文 ...
- javascript做表_使用JavaScript构建HTML表
javascript做表 In this article I will demonstrate three ways of creating and populating an HTML table ...
- python中configparser详解_python ConfigParser模块详解
功能介绍 在程序中使用配置文件来灵活的配置一些参数是一件很常见的事情,配置文件的解析并不复杂,在python里更是如此,在官方发布的库中就包含有做这件事情的库,那就是ConfigParser,这里简单 ...
- python内置库之学习configparser库(一)
python内置库之学习configparser库(一) 1.引言 ini文件简介 [节] 键=值 注:节不能重复出现 2.自己封装了一个增删改查的类,可以参考一下 import configpars ...
最新文章
- 计算机基础-计算机硬件
- 字符串匹配KMP算法
- Activity Stack
- 如何用你最熟悉的 SQL 来查询 Elasticsearch 中的数据?
- 当Windows Vista提示“内存不足”……
- JAVA数据类型与逻辑练习
- [html] html如何启动本地的exe应用?
- matlab中的libsvm怎么录入数据啊,LibSVM在MATLAB中使用时的几个问题
- C语言 sprintf 函数 - C语言零基础入门教程
- [Turn]C# 强制关闭当前程序进程(完全Kill掉不留痕迹)
- [转载] 老版本ubuntu 更新源
- win7右下角无线网图标显示未连接,但是实际上已连接上,也能上网
- 在kettle中实现数据验证和检查
- phpcms v9 邓士鹏(石家庄职业技术学院)
- 面对人生这道程序,该如何编码?
- Windows 10系统下Outlook日历怎么显示农历?
- 为什么计算机无法打开扫描机,为什么打印机无法扫描 打印机无法扫描是什么原因 - 云骑士一键重装系统...
- 联通宽带开启 IPV6 的方法
- 事件代理(冒泡机制)
- 电子秤c语言编程,基于AT89C51的数字电子秤的设计最终版(样例3)
热门文章
- 写专业书确能帮助自己快速提升——写在我的书出版半年后,同时和大家分享选书的方式...
- (原创)Python 自动化测试框架详解
- 放肆的使用UIBezierPath和CAShapeLayer画各种图形
- [新手学Java]使用beanUtils控制javabean
- android中Stub Proxy答疑
- C#日期函数所有样式大全
- python读取us7ascii字符集Oracle数据库中文乱码问题的解决方案
- Python常见问题解决记录1-Non-ASCII character ‘\xe7‘错误
- WebAPI Get
- php -- PDO异常处理