求列表中指定元素的位置
1 #!/usr/bin/env python 2 #_*_ coding:utf-8 _*_ 3 name = ['hello', 'world', 'a', 'b', 'c', 1, 2, 3, 'hello', 'world', 'a', 'b', 'c', 1, 2, 3] 4 first_pos = 0 5 for i in range(name.count(2)): 6 new_list = name[first_pos:] 7 next_pos = new_list.index(2) + 1 8 print 'find ', first_pos + new_list.index(2) 9 first_pos += next_pos