python贪婪匹配中的错误

2024-06-26 14:18:49 发布

您现在位置:Python中文网/ 问答频道 /正文

import re
greedyHaRegex = re.compile(r'(Ha){3, 5}')
mo1 = greedyHaRegex.search('HaHaHaHaHa')
mo1.group()
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    mo1.group()
AttributeError: 'NoneType' object has no attribute 'group'

我不明白为什么会发生这个错误


Tags: importremostsearchgroupcallfilelast