ParsingError:ConfigParser Python

ParsingError:ConfigParser Python,python,python-3.x,configparser,Python,Python 3.x,Configparser,我正在使用读取ini文件。然而,我得到了,这可以在下面看到: [line 2]: ' % ---------------- File created by User ----------------------\n' [line 9]: ' % ---------------------------------------------------------------------------\n' [line 11]: ' % ----------------------------

我正在使用读取ini文件。然而,我得到了,这可以在下面看到:

[line  2]: '  % ---------------- File created by User ----------------------\n'
[line  9]: '  % ---------------------------------------------------------------------------\n'
[line 11]: '  % ---------------------------------------------------------------------------\n'
我不能使用选项“allow_no_value=True”,因为第9行和第11行是相同的,并且在文档中

示例文档如下所示:

'  % ---------------- File created by User ----------------------\n'

[OrderID]
    orderName       = Ord1           
    orderNumber     = Ord2#02        
import configparser

config = configparser.ConfigParser()
config.read(path,encoding='cp1250')
有没有办法解析文档?我目前使用的代码如下:

'  % ---------------- File created by User ----------------------\n'

[OrderID]
    orderName       = Ord1           
    orderNumber     = Ord2#02        
import configparser

config = configparser.ConfigParser()
config.read(path,encoding='cp1250')

感谢
configparser
文档中的:“配置解析器允许大量定制。”

特别是,您可以指定
引入注释行

import configparser

config = configparser.ConfigParser(comment_prefixes=("#", ";", "'"))
config.read(path, encoding='cp1250')

请参阅:

为什么您的ini文件中有这样的行?@user2357112 ini文件是由系统生成的。谢谢您的帮助。我再次检查了文档,“inline_comment_prefixes”对我很有用。