且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

“at"是什么意思?(@) 符号在 Python 中做什么?

更新时间:2023-11-08 13:40:34

行首的 @ 符号用于类、函数和方法装饰器.

An @ symbol at the beginning of a line is used for class, function and method decorators.

在此处阅读更多信息:

PEP 318:装饰器

Python 装饰器

您将遇到的最常见的 Python 装饰器是:

The most common Python decorators you'll run into are:

@property

@classmethod

@staticmethod

如果你在一行的中间看到一个 @,那就是另一回事了,矩阵乘法.请参阅此答案,显示将 @ 用作二元运算符.

If you see an @ in the middle of a line, that's a different thing, matrix multiplication. See this answer showing the use of @ as a binary operator.