谁能帮我写一个循环,它接受一个数据列表,并检查数据中的值是否大于前一个值,也大于下一个值。也就是说,我试图在一组峰值中找到峰值数据点。
发布于 2017-04-17 09:50:26
你可以像这样写一个循环:
lst = [1,5,3,2,4,1]
for i in range(1, len(lst)-1):
if lst[i - 1] < lst[i] and lst[i] > lst[i + 1]:
print(i, lst[i])Python教程:
https://stackoverflow.com/questions/43444027
复制相似问题