python for loop, how to find next value(object)?

后端 未结 4 1035
Happy的楠姐
Happy的楠姐 2020-12-18 11:44

HI, I\'m trying to use for loop to find the difference between every two object by minus each other. So, how can I find the next value in a for loop?

for ent         


        
4条回答
  •  天命终不由人
    2020-12-18 12:05

    i don't know exactly what are you looking but maybe this can help :

    first = entries[0]
    for entry in entries[1:]:
        last = entry       
        diff = last - first 
        first = entry
    

提交回复
热议问题