小编Rui*_*Rui的帖子

sre_constants.error:在位置 2 处多次重复

我试图匹配+和之间的所有子字符串h,例如+abcd1234h.

代码如下:

match = re.match(r'.*+(.*)h.*',line)
Run Code Online (Sandbox Code Playgroud)

当我运行我的代码时,发生如下错误:

File "C:\Program Files\Python\Python36\lib\re.py", line 172, in match
    return _compile(pattern, flags).match(string)

  File "C:\Program Files\Python\Python36\lib\re.py", line 301, in _compile
    p = sre_compile.compile(pattern, flags)

  File "C:\Program Files\Python\Python36\lib\sre_compile.py", line 562, in compi
le
    p = sre_parse.parse(p, flags)

  File "C:\Program Files\Python\Python36\lib\sre_parse.py", line 855, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)

  File "C:\Program Files\Python\Python36\lib\sre_parse.py", line 416, in _parse_
sub
    not nested and not items))

  File "C:\Program Files\Python\Python36\lib\sre_parse.py", line 619, in _parse …
Run Code Online (Sandbox Code Playgroud)

python regex python-3.x

6
推荐指数
0
解决办法
4482
查看次数

标签 统计

python ×1

python-3.x ×1

regex ×1