python - Python 中的 '@=' 符号是什么?

我知道 @ 是用于装饰器的,但是 @= 在 Python 中是什么?是否只是为一些 future 的想法保留?

这只是我在阅读 tokenizer.py 时遇到的众多问题之一。

最佳答案

来自 the documentation :

The @ (at) operator is intended to be used for matrix multiplication. No builtin Python types implement this operator.

@ 运算符是在 Python 3.5 中引入的。 @= 是矩阵乘法,然后是赋值,正如您所期望的那样。它们映射到 __matmul____rmatmul____imatmul__,类似于 ++=映射到 __add____radd____iadd__

PEP 465 中详细讨论了运算符及其背后的原理。 .

关于python - Python 中的 '@=' 符号是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27385633/

相关文章:

linux - 是否可以在文件名中使用 "/"?

python - 如何将 NumPy 数组标准化为单位向量?

python - 是否可以使用 scikit-learn K-Means Clustering 指定

linux - 如何在行号处拆分文件

c - 如何从 C 中通过 PID 在 Linux 中计算进程的 CPU 使用率?

python - Python 3 的图像库

python - Python 中嵌套的 try/except block 是一种好的编程习惯吗?

linux - grep 排除多个字符串

python - Python 'for' 循环中的范围

c - 从C中的文件描述符中检索文件名