我正在尝试创建一个函数来测试函数是否存在,然后根据它是否存在返回一个布尔值.
这是我的代码; 但是,Python IDLE 3.5告诉我,我的eval()语句有错误,但我没有看到错误:
def testFunction(entity):
try eval(entity)():
return True
except NameError:
return False
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
我在Java中创建了一个ActionListener按钮
d1.addActionListener(this);
Run Code Online (Sandbox Code Playgroud)
给了我一个关于"这个"的错误,但是
d1.addActionListener((ActionListener) this);
Run Code Online (Sandbox Code Playgroud)
作品.为什么我需要添加"(ActionListener)"?我在教程中看到第一个应该工作; 为什么不适合我?