当前位置:网站首页>Pit of the start attribute of enumrate

Pit of the start attribute of enumrate

2022-07-02 11:12:00 lanmy_ dl

enumrate Of start attribute

That's true , Two, please for Loop traversal , Take out the data , And the second for The loop can be taken after the first one to save processing time , I used it enumerate, It turns out that start The attribute is different from what I think start Attribute specification

    for index1,((xx1, yy1), rr1, grbb1) in enumerate(center): #  From the first point 
        for index2,((xx2, yy2), rr2, grbb2) in enumerate(center,start=index1+1):
        ###code

Even if the subscript becomes 1, Or with the 0 Same
 Insert picture description here

It turned out that it was just changing the subscript of the starting value , Or I'll go through it from the beginning , Although the subscript record has changed , But the data is still taken from scratch ...

It's better to be honest for Loop handle , Suddenly I understand that there are sometimes two in the general training code for loop

for index1 in range(len(center)):
	(xx1, yy1), rr1, grbb1 = center[index1]
	for index2 in range(index+1,len(center)):
		(xx2, yy2), rr2, grbb2) = center[index2]
		###code
原网站

版权声明
本文为[lanmy_ dl]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/183/202207020744083231.html