【发布时间】:2013-06-23 11:10:41
【问题描述】:
Test Array = [1, 2, 3, 1, 0.4, 1, 0.1, 0.4, 0.3, 1, 2]
我需要遍历一个数组,以找到第一次 3 个连续条目
Test Array = [1, 2, 3, 1, 0.4, 1, 0.1, 0.4, 0.3, 1, 2]
^ ^ ^ ^
(indices) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
^
所以在这个测试数组中,正在寻找的索引/值是 6
除了提出的解决方案之外,如果不满足“3 个连续值
(如果不满足条件,我希望返回值为0)
【问题讨论】:
-
http://stackoverflow.com/questions/176918/in-python-how-do-i-find-the-index-of-an-item-given-a-list-containing-it此链接可能对您有所帮助。
标签: python arrays list loops compare