admin管理员组文章数量:1611136
re.error: bad escape \s at position 0
问题展示:
Traceback (most recent call last):
File “C:/workspace/DeepLog-master/DeepLog/ParseByShell.py”, line 19, in
parser.parse(log_file)
File “C:\workspace\DeepLog-master\DeepLog\logparser\Spell\Spell.py”, line 231, in parse
self.load_data()
File “C:\workspace\DeepLog-master\DeepLog\logparser\Spell\Spell.py”, line 276, in load_data
headers, regex = self.generate_logformat_regex(self.logformat)
File “C:\workspace\DeepLog-master\DeepLog\logparser\Spell\Spell.py”, line 312, in generate_logformat_regex
splitter = re.sub(r’ +', ‘\s+’, splitters[k])
File “C:\anaconda3\lib\re.py”, line 192, in sub
return _compile(pattern, flags).sub(repl, string, count)
File “C:\anaconda3\lib\re.py”, line 309, in _subx
template = _compile_repl(template, pattern)
File “C:\anaconda3\lib\re.py”, line 300, in _compile_repl
return sre_parse.parse_template(repl, pattern)
File “C:\anaconda3\lib\sre_parse.py”, line 1024, in parse_template
raise s.error(‘bad escape %s’ % this, len(this))
re.error: bad escape \s at position 0
解决方案:
I dealt with a similar issue (sre_constants.error: bad escape \p at position 1) and the solution was to
import regex and use regex.sub instead of re.sub.
使用regex代替re。即
import regex as re
本文标签: ErrorPythonbadPositionEscape
版权声明:本文标题:【Python】re.error: bad escape s at position 0 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1728606693a1165544.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论