Python 此输出的具体名称是什么?

Python 此输出的具体名称是什么?,python,function,higher-order-functions,Python,Function,Higher Order Functions,我制作了一个名为“function”的函数,如下所示 >>> def function(): return 'hello world' >>> function <function function at 0x7fac99db3048> #this is the output 这个输出到底是什么?具体名字是什么?这有什么意义? 我知道它提供了关于内存位置的信息。但是我需要更多关于这个输出的信息 高阶函数在返回函数时是否返回类似的

我制作了一个名为“function”的函数,如下所示

>>> def function():
        return 'hello world'

>>> function
<function function at 0x7fac99db3048> #this is the output
这个输出到底是什么?具体名字是什么?这有什么意义? 我知道它提供了关于内存位置的信息。但是我需要更多关于这个输出的信息


高阶函数在返回函数时是否返回类似的数据

要调用该函数,需要使用调用。如果没有,您将看到对存储在0x7fac99db3048的函数的引用。您也可以将其存储在另一个变量中,如下所示:

>>> my_new = function  # store function object in different variable

>>> function
<function function at 0x10502bc80>
#                      ^ memory address of my system

>>> my_new
<function function at 0x10502bc80>
#                      ^ same as above

>>> my_new()    # performs same task
'hello world'

在python中,函数是一个对象,因此当您调用函数时,它会返回内存地址。高阶函数的行为方式相同。但也存在一些差异:

def a():
    print("Hello, World!")

def b():
    return a

>>> a
<function a at 0x7f8bd15ce668>
>>> b
<function b at 0x7f8bd15ce6e0>

c = b

>>>c
<function b at 0x7f8bd15ce6e0>

c = b()
<function a at 0x7f8bd15ce668>

注意函数c在不同情况下返回的内容。

这不是他们的问题
def a():
    print("Hello, World!")

def b():
    return a

>>> a
<function a at 0x7f8bd15ce668>
>>> b
<function b at 0x7f8bd15ce6e0>

c = b

>>>c
<function b at 0x7f8bd15ce6e0>

c = b()
<function a at 0x7f8bd15ce668>