我一直在尝试使用正则表达式,并尝试继承从re.search返回的MatchObject类。
但是我无法访问MatchObject类。
我猜测这个对象的实际类型不叫"MatchObject":
>>> re.search ("a", "a")
<_sre.SRE_Match object at 0x100427a58>
然而,我无法访问该对象:
import _sre
dir (_sre)
['CODESIZE', 'MAGIC', '__doc__', '__name__', '__package__', 'compile', 'copyright', 'getcodesize', 'getlower']
>>> dir(_sre.SRE_Match)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SRE_Match'
我错过了什么?