2024-04-19 09:24:12 发布
网友
在阅读一些Python(PyQt)代码时,我发现如下所示。在
@pyqtSignature("QString") def on_findLineEdit_textEdited(self, text): self.__index = 0 self.updateUi()
这是如何工作的?Python如何处理这个@?在
@
它是function decorators的语法。
它是decorator语法,简单地说它等价于以下形式:
on_findLineEdit_textEdited = pyqtSignature("Qstring")(on_findLineEdit_textEdited)
真的很简单。
典型的decorator将必须修饰的函数作为第一个参数,并对其执行stuff/添加功能。一个典型的例子是:
步骤如下:
f
它是function decorators的语法。
它是decorator语法,简单地说它等价于以下形式:
真的很简单。
典型的decorator将必须修饰的函数作为第一个参数,并对其执行stuff/添加功能。一个典型的例子是:
^{pr2}$步骤如下:
f
添加功能的新函数相关问题 更多 >
编程相关推荐