列表最近我只好找哪个列表的东西是我用:Python中找到一个值列表
def findPoint(haystack, needle): # haystack = [[1,2,3], [4,5]...,[6,7,8,9]]
for x in range(len(haystack)):
if needle in haystack[x]:
return x
raise Exception("needle: " + str(needle) + " not in haystack")
有一个haystack.index(针)方法。 问题是:“有没有更好的方法来做到这一点?”
我用的是指数在另一个类似的功能这个。 'if index1!= index2:haystack [index1] .extend(haystack.pop(index2))' – mbowden