如何在一个字符串中获取相同单词的跨度ID?

时间:2018-01-20 07:57:11

标签: python python-3.x

在这个问题上,我在Python的Re Module中使用了搜索功能,但我能够获得第一个单词的Span ID

string2="Jhon is a good boy,Jhon is brilliant,Jhon is a data scientist,Jhon is Jhon"
m=re.search("Jhon",string2)
print(m)

我正在这样输出

<_sre.SRE_Match object; span=(0, 4), match='Jhon'>

此输出(Span ID)仅适用于第一个单词,请告诉我有没有办法为所有“Jhon”找到Span ID

0 个答案:

没有答案