Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.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 2.7 python函数作为参数传递给另一个函数_Python 2.7 - Fatal编程技术网

Python 2.7 python函数作为参数传递给另一个函数

Python 2.7 python函数作为参数传递给另一个函数,python-2.7,Python 2.7,我不熟悉pragraming和python。这有点像我所拥有的 Def some_function(): Print "stuff" Def another_function(x): running = True While running: x another_function(some_function()) 为什么第一次循环时它只打印“东西” 我读了一些关于后期绑定的文章,但不确定这是什么或者如何在我的示例中修复它 您没有传递函数,

我不熟悉pragraming和python。这有点像我所拥有的

 Def some_function():
     Print "stuff"

 Def another_function(x):
     running = True
     While running:
         x

another_function(some_function())
为什么第一次循环时它只打印“东西”


我读了一些关于后期绑定的文章,但不确定这是什么或者如何在我的示例中修复它

您没有传递函数,而是调用了函数并传递了它的值。所以它在你进入循环之前就打印了
东西

要在不调用函数的情况下引用函数,请关闭
()
。因此,它应该是:

another_function(some_function);
然后,在另一个函数中,您必须调用该函数:

def another_function(x):
    running = True
    while running:
        x()