Function 将一个函数嵌入另一个Jython
赋值的目标是使这两个函数一起工作,即将setPixeltoBlack调用到setPicturetoblack中 错误很明显:Function 将一个函数嵌入另一个Jython,function,jython,Function,Jython,赋值的目标是使这两个函数一起工作,即将setPixeltoBlack调用到setPicturetoblack中 错误很明显: The error was:'javainstance' object has no attribute '__call__' Attribute not found. You are trying to access a part of the object that doesn't exist. Please check line 10 of /Users/tobia
The error was:'javainstance' object has no attribute '__call__'
Attribute not found.
You are trying to access a part of the object that doesn't exist.
Please check line 10 of /Users/tobiasdouglas/test3
主要问题:如何让计算机检查xpos和ypos是否存在两个变量?
我写了一个psedoocode,上面显示了所需的内容
谢谢
import random
file=pickAFile()
picture=makePicture(file)
show(picture)
xpos = input("Enternumber")
ypos = input("Enternumber")
def setPixelToBlack(getPixel):
#if xpos and ypos = known
setColor=(getPixel(picture,xpos,ypos),black)
#else
#setcolor=(getPixels(picture), black)
explore(picture)
return
def setPictureToBlack(picture):
for p in getPixels(picture):
setPixelToBlack(p)
您可以使用specal value None,并检查变量是否为None以及是否为None
在代码中,xpo和ypo也是全局变量。您可以在函数中读取它们,但要更改其值,需要使用全局xpos、ypos语句
xpos = None
ypos = None
// some code that may set xpos or ypos
def setPixelToBlack(getPixel):
if xpos is not None and ypos is not None:
setColor=(getPixel(picture,xpos,ypos),black)
// ...