请问func()在python中在函数中使用时是什么意思 [英] Please what does func() mean in python when used inside a function
本文介绍了请问func()在python中在函数中使用时是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请问func()在python中在函数内部使用时是什么意思,例如在下面的代码中.
def identity_decorator(func):定义包装器():功能()返回包装器
解决方案
func
是给函数 identity_decorator()
的参数.
表达式 func()
的意思是调用分配给变量 func
的函数."
装饰器将另一个函数作为参数,并返回一个新函数(定义为 wrapper
),该函数在运行时执行给定的函数 func
.>
这里是关于装饰器的一些信息.
Please what does func() mean in python when used inside a function,For example in the code below.
def identity_decorator(func):
def wrapper():
func()
return wrapper
解决方案
func
is an argument given to the function identity_decorator()
.
The expression func()
means "call the function assigned to the variable func
."
The decorator is taking another function as an argument, and returning a new function (defined as wrapper
) which executes the given function func
when it is run.
Here is some information about decorators.
这篇关于请问func()在python中在函数中使用时是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文