在Python中确定从Regex搜索返回的组数

2024-05-23 18:42:18 发布

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

我在python中执行regex搜索,如下所示:

import re
regexSearch = re.search(r'FTP-exception-sources-\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', line, re.M|re.I )
if regexSearch:
        outputFile2.write(str(lineCounter) + " , " + regexSearch.group(0) + "\n")

如何确定从regex搜索返回的groups的数目?在


Tags: importresearchiflineexceptiongroupftp