我有一个类似如下的列表: ls = ['item1', 'this is item2', 'item3'] 我希望能够通过搜索'item2'来找到项目'this is item2'的索引。index函数正在查找完全匹配的内容,因此它在这里不起作用: index = ls.index('item2') 我如何才能达到这个要求?
我是编程新手,当我使用python时,我发现'in‘操作在不同数据结构上的性能有很大的不同。set(list_b)s=0 if entry in b:t2=time()我以这样的结果结束,这是非常有效的但是,当我搜索list_b而不更改为设置数据结构时b=list_bs=0
for entry in a:或者在python<