我有一个 list
myList = ["what is your name", "Hi, how are you",
"What about you", "How about a coffee", "How are you"]
现在我要搜索
"How"
和"what"
的所有出现的索引。我该如何用Pythonic方式做到这一点? 最佳答案
听起来像是单线Python就能做到的!
[i for i, j in enumerate(myList) if 'how' in j.lower() or 'what' in j.lower()]
关于python - 查找列表中多个项目的索引,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30729735/