【发布时间】:2016-03-14 02:02:19
【问题描述】:
我正在尝试将 isdigit() 添加到程序中,以便我可以验证用户输入的内容是否有效。这是我到目前为止所拥有的。但是当我运行它并输入一个字符时,说“f”。它崩溃并给我将在代码下方发布的错误。有什么想法吗?
def mirrorHorizontal(source):
userMirrorPoint = requestString("Enter a mirror point from 0 to halfway through the pitcure.") #asks user for an input
while (int(userMirrorPoint) < 0 or int(userMirrorPoint) > (int(getHeight(source) - 1)//2)) or not(userMirrorPoint.isdigit()):
userMirrorPoint = requestString("Enter a mirror point from 0 to halfway through the pitcure.")
height = getHeight(source)
mirrorPoint = int(userMirrorPoint)
for x in range(0, getWidth(source)):
for y in range(0, mirrorPoint):
topPixel = getPixel(source, x, y)
bottomPixel = getPixel(source, x, height-y-1)
color = getColor(topPixel)
setColor(bottomPixel, color)
错误是:f 不适当的参数值(正确类型)。 尝试将参数传递给函数时发生错误。 请查看 /Volumes/FLASHDRIVE2/College/Spring 16'/Programs - CPS 201/PA5Sikorski.py 的第 182 行
【问题讨论】:
标签: jes jython-2.5