listEx = ['cat *(select: "Brown")*', 'dog', 'turtle', 'apple']
listEx2 = ['hampter',' bird', 'monkey', 'banana', 'cat']
for j in listEx2:
for i in listEx:
if j in i:
print listEx.index(j)
我想要做的是在listEx中搜索listEx2中的项目。如果在listEx中找到了来自listEx2的项目,我想知道如何打印出在listEx中找到的来自listEx2的项目的索引值。谢谢!
'cat'
吗?因为它包含在'cat *(select: "Brown")*'
中吗? - Mark ByerslistEx
中包含多个字符串“cat”,那么应该发生什么?您想要它们所有的索引吗? - Mark Byers