Python中re.compile遇到only supports 100 named groups的问题
2016-07-12 08:24
666 查看
#牧飞(mufei)
#Python中re.compile遇到only supports 100 named groups的问题
今天要Python弄个正则表达式来匹配, 发现有个"AssertionError: sorry, but this version only supports 100 named groups"错误.
>>> import re
>>> re.compile('(.moofei)'*100)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\lib\re.py", line 194, in compile
return _compile(pattern, flags)
File "C:\Python27\lib\re.py", line 249, in _compile
p = sre_compile.compile(pattern, flags)
File "C:\Python27\lib\sre_compile.py", line 583, in compile
"sorry, but this version only supports 100 named groups"
AssertionError: sorry, but this version only supports 100 named groups
网上搜了一下解决办法都是用for循环来匹配来解决.
我想了一下不用命名groups也可以解决问题, 在.前面加个?:完美解决问题.
>>> re.compile('(?:.mufei)'*100)
<_sre.SRE_Pattern object at 0x0000000004AAEAA0>
#Python中re.compile遇到only supports 100 named groups的问题
今天要Python弄个正则表达式来匹配, 发现有个"AssertionError: sorry, but this version only supports 100 named groups"错误.
>>> import re
>>> re.compile('(.moofei)'*100)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\lib\re.py", line 194, in compile
return _compile(pattern, flags)
File "C:\Python27\lib\re.py", line 249, in _compile
p = sre_compile.compile(pattern, flags)
File "C:\Python27\lib\sre_compile.py", line 583, in compile
"sorry, but this version only supports 100 named groups"
AssertionError: sorry, but this version only supports 100 named groups
网上搜了一下解决办法都是用for循环来匹配来解决.
我想了一下不用命名groups也可以解决问题, 在.前面加个?:完美解决问题.
>>> re.compile('(?:.mufei)'*100)
<_sre.SRE_Pattern object at 0x0000000004AAEAA0>
相关文章推荐
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- install and upgrade scrapy
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- Python中zip()函数用法举例
- Python中map()函数浅析
- msql 正则表达式
- 正则表达式
- Python将excel导入到mysql中
- Python在CAM软件Genesis2000中的应用
- 使用Shiboken为C++和Qt库创建Python绑定
- FREEBASIC 编译可被python调用的dll函数示例