logo

关于if的判断条件语句

2018-03-06 14:38
F
_13485010993
b08310d3-9002-42a7-86de-f8dee35a9f98.png

请教这个如何解决,多谢~

I
网红小智智 星瞳科技

你发一下代码,参考<https://forum.singtown.com/topic/57/%E7%8E%A9%E8%BD%AC%E6%98%9F%E7%9E%B3%E8%AE%BA%E5%9D%9B>

2018-03-06 14:47
F
_13485010993

for y in range(10, 109, 20):

for x in range(0, 159):

t1 = img.get_pixel(x,y) #获取坐标像素rgb

t2 = img.get_pixel(x+1,y)

t3 = img.get_pixel(x+2,y)

t4 = img.get_pixel(x+3,y)

t5 = img.get_pixel(x+4,y)

t6 = img.get_pixel(x+5,y)

***if (t1[0]==0 and t2[0]==0 and t3[0]==255 and t4[0]==255 and t5[0]==255):***

a1 = x+2

主要是IF语句,如果只判断两个:if((t1[0]==0 and t2[0]==255): , 这样是可以的,如果and多个条件就会报错。。。。。

(缩进格式可以忽略。。。。)

F
_13485010993

@kidswong999 哦 好像是超出范围了,如果x到159的话,再加的就会超出像素范围

I
网红小智智 星瞳科技

是的,超出范围了,返回值就是none