2021
01-29
01-29
python re.match()用法相关示例
学习python爬虫时遇到了一个问题,书上有示例如下:importreline='Catsaresmarterthandogs'matchObj=re.match(r'(.*)are(.*?).*',line)ifmatchObj:print('matchObj.group():',matchObj.group())print('matchObj.group(1):',matchObj.group(1))print('matchObj.group(2):',matchObj.group(2))else:print('Nomatch!\n')书上的期望输出是:matchObj.group():CatsaresmarterthandogsmatchObj.group(1):Catsmat...
继续阅读 >