pola2 = [['%3C','%28'],['%3C','document.cookie','%3B'],['%3C','%28','%27','4'],['%3C','document.cookie','%3B','4','5'],['%3C','document.cookie','%3B','4','5','6']]
#find the longest list in list
a = max(pola2, key=len)
print a
#result ['%3C', 'document.cookie', '%3B', '4', '5', '6']
#how if end of result is index "4" or position "5"
如何打印print a
在pola2
列表中的索引4或位置5中显示的结果?
答案 0 :(得分:0)
尝试下面的代码:
pola2 = [['%3C','%28'],['%3C','document.cookie','%3B'],['%3C','%28','%27','4'],['%3C','document.cookie','%3B','4','5'],['%3C','document.cookie','%3B','4','5','6']]
a = max(pola2, key=len)
print pola2.index(a)
应该工作正常。这个问题有点重复,请参阅:Finding the index of an item given a list containing it in Python