我写错了一个程序。def changeByThirds(pic):
w= getWidth (pic)
h = getHeight(pic)
newPic = makeEmptyPicture(w,h)
for x in range (0,w):
for y in range (0,h):
pxl = getPixel(pic, x, y)
if (y
#some code
if (y>(h*2/3)):
#some code
else:
#some code
return (newPic)
当我执行这个程序时,第一个if语句if (y(h*2/3)):
#some code
else:
#some code
我发现正确的代码编写方法如下:def changeByThirds(pic):
w= getWidth (pic)
h = getHeight(pic)
newPic = makeEmptyPicture(w,h)
for x in range (0,w):
for y in range (0,h):
pxl = getPixel(pic, x, y)
if (y
#some code
elif (y>(h*2/3)):
#some code
else:
#some code
return (newPic)
然而,我的问题是
在第一个代码中-为什么要绕过第一个if语句?