Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么re2的结果与Python中的re模块不同?_Python_Regex_Re2 - Fatal编程技术网

为什么re2的结果与Python中的re模块不同?

为什么re2的结果与Python中的re模块不同?,python,regex,re2,Python,Regex,Re2,我试着用 结果: cde 1 Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'NoneType' object has no attribute 'group' 但re2的结果不同 import re2 print re2.search('cde', 'abcdefg').group(0) 结果: cde 1 Traceback (

我试着用

结果:

cde
1
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'group'
但re2的结果不同

import re2
print re2.search('cde', 'abcdefg').group(0)
结果:

cde
1
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'group'
1
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
AttributeError:“非类型”对象没有属性“组”
  • 为什么每次执行新的字符串模式时都输出编号
    re2
    1
  • 如何隐藏数字1
  • 为什么
    re模块的结果不同(未找到=>返回无)
  • re2版本是0.2.20。Python版本是2.7


    谢谢

    这是0.2.20版的错误。看看这个或这个。您最好从github克隆源代码,然后安装它。不要通过pip安装。

    哦,这个问题已经通过github版本解决了。非常感谢。