我有一个字符串列表,需要查找其中是否包含 'American'
这个单词。如果存在,我想找到这个单词的起始和结束索引。
['Here in Americans, people say “Can I get a bag for the stuff?”',
'Typically in restaurant after you are done with meal, you ask for check in Americans from the waiter.',
'When mixing coffee, people in American use creamer, which is equivalent of milk.']
希望输出:查找“American”单词的起始和结束索引。
8,16
75,83
30,38
find
方法总是返回第一个索引,因此不适合解决这个问题... - yuvgin