Python Jython中的用户输入验证
我一直在尝试使用Jython环境为学生进行镜像作业 我正在寻求从用户那里请求一条任意线,我将使用它来镜像图像,这条线必须从图像边缘到边缘,并且是对角线Python Jython中的用户输入验证,python,jython,jes,Python,Jython,Jes,我一直在尝试使用Jython环境为学生进行镜像作业 我正在寻求从用户那里请求一条任意线,我将使用它来镜像图像,这条线必须从图像边缘到边缘,并且是对角线 def userCoordinates(): pic = makePicture(pickAFile()) height = getHeight(pic) width = getWidth(pic) newPic = makeEmptyPicture, (width, height) startX = requestIntege
def userCoordinates():
pic = makePicture(pickAFile())
height = getHeight(pic)
width = getWidth(pic)
newPic = makeEmptyPicture, (width, height)
startX = requestInteger("Please enter your startX Coordinate")
while startX > width:
startX = requestInteger("Error, this coordinate is outside the image, please enter your startX Coordinate")
else:
print "Your startX coordinate is", startX
startY = requestInteger("Please enter your startY Coordinate")
while startY > height:
startY = requestInteger("Error, this coordinate is outside the image, please enter your startY Coordinate")
else:
print "Your startY coordinate is", startY
endX = requestInteger("Please enter your endX Coordinate")
while endX > width:
endX = requestInteger("Error, this coordinate is outside the image, please enter your endX Coordinate")
else:
print "Your endX coordinate is", endX
endY = requestInteger("Please enter your endY Coordinate")
while endY > height:
endY = requestInteger("Error, this coordinate is outside the image, please enter your endY Coordinate")
else:
print "Your endY coordinate is", endY
是否有任何方法可以验证选定的点是否位于图像的边缘上?或者用一种更好的(更干净的方式)来做上述工作。我在各方面都是初学者
我尝试在startX时使用它!=0或startX!=宽度
但是这样做是行不通的,因为X实际上可以是任何东西
任何帮助都将不胜感激