Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 类型错误:';int';对象在作为函数参数发送函数时不可调用_Python_Function_Parameters_Typeerror - Fatal编程技术网

Python 类型错误:';int';对象在作为函数参数发送函数时不可调用

Python 类型错误:';int';对象在作为函数参数发送函数时不可调用,python,function,parameters,typeerror,Python,Function,Parameters,Typeerror,我从这个代码中得到一条错误消息 def make_lazy(*args): # implement here return args[0](args[1], args[2]) TypeError:“int”对象不可调用 这段代码在Python3.5.0中工作,但Python2.7.6显示了错误。 如何为python 2.7.6更正此代码?如何调用它?args[0]是int而不是函数。我称之为make_lazy(add,2,3)。add是另一个函数。我想调用一个函数作为函数参数

我从这个代码中得到一条错误消息

def make_lazy(*args):
    # implement here
    return args[0](args[1], args[2])
TypeError:“int”对象不可调用
这段代码在Python3.5.0中工作,但Python2.7.6显示了错误。
如何为python 2.7.6更正此代码?

如何调用它?
args[0]
int
而不是
函数。我称之为make_lazy(add,2,3)。add是另一个函数。我想调用一个函数作为函数参数。就像@Vishnu所说的,返回args[0](args[1],args[2]),args[0]不是函数。如果第一个参数是函数,我应该工作。您确定没有将函数名作为变量重用吗?如果您发送一个完整的示例,诊断起来会容易得多。