python在字符串中查找子字符串位置(子字符串在字符串中的位置)

2024-07-01 07:34:28 发布

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

我想找出每个“e”在句子中的位置,这样以后我就可以对它做一些代码了。在

sentence="joey is one of the best comedians of all time"
letter_positions=sentence.find('e')
print(letter_positions)

结果是2。在

我尝试使用letter_positions=sentence.findAll('e')

但没用,有个错误。在


Tags: ofthe代码timeisallfindone

热门问题