我正在做一个简单的查找
if xo.st in sts:
#...
如果满足条件,我需要获取 sts 中元素的索引(sts 是列表或元组)。这需要快速(这是一个大列表)。最好的解决方案是什么?
请您参考如下方法:
关于:
if xo.st in sts:
print sts.index(xo.st)
这将返回 sts 中 xo.st 的第一个索引
我正在做一个简单的查找
if xo.st in sts:
#...
如果满足条件,我需要获取 sts 中元素的索引(sts 是列表或元组)。这需要快速(这是一个大列表)。最好的解决方案是什么?
请您参考如下方法:
关于:
if xo.st in sts:
print sts.index(xo.st)
这将返回 sts 中 xo.st 的第一个索引