我正在遵循學習正則表達式的說明:In [269]: phone_number_regexOut[269]: re.compile(r'\d\d\d-\d\d\d-\d\d\d\d', re.UNICODE)In [270]: mo = phone_number_regex.search("My number is 415-555-4242")In [273]: mo.group()Out[273]: '415-555-4242'In [274]: help(mo.group)_sre.SRE_Match 實例group([group1, ...]) -> str 或元組的group(...) 方法。按索引或名稱返回匹配項的子組。為0時返回整個匹配項。sre.SRE這里指的是什么?這不是bulitin方法:In [285]: [ elem for elem in dir(mo.group) if "_sre" in elem]Out[285]: []
1 回答

慕桂英4014372
TA貢獻1871條經驗 獲得超13個贊
該reLIB實際上主要是一個C擴展包用Python包裝了它。_sre是 C 擴展模塊并且_sre.SRE_Match是(C 編碼)Match類。你會在sys.modules:
>>> import sys
>>> import re
>>> sys.modules["_sre"]
<<module '_sre' (built-in)>
添加回答
舉報
0/150
提交
取消