ini是这样
[1]
name = 上涨数字
options = (上涨|涨超|涨|涨逾|涨幅|涨幅达|涨约涨近|涨幅扩大至|急升)\d+.?\d*%?
events = 股价上涨
label = \d+.?\d*
在使用compile的时候出现了一些问题
pattern = re.compile(self.config[‘1’][‘options’])
ConfigParser.InterpolationSyntaxError: ‘%’ must be followed by ‘%’ or ‘(’, found: “%&’” 解决方案
源码:
self.config = configparser.ConfigParser()
修改:
self.config = configparser.RawConfigParser()
原因:
可能是因为ConfigParse不是按行读取,而是使用一些%等特殊符号来区分,所以修改为Raw形式每行读取即可