Jja*_*ang 1 python operator-overloading python-3.x
在python 3中,我想在我创建的类中进行运算符重载.
我知道__add__代表运营商+.
有哪些方法-,*,^,|和&?
请参阅数据模型上的python文档.
您询问的方法有:__sub__,__mul__,__xor__,__or__和__and__
这是完整列表:
object.__add__(self, other)
object.__sub__(self, other)
object.__mul__(self, other)
object.__truediv__(self, other)
object.__floordiv__(self, other)
object.__mod__(self, other)
object.__divmod__(self, other)
object.__pow__(self, other[, modulo])
object.__lshift__(self, other)
object.__rshift__(self, other)
object.__and__(self, other)
object.__xor__(self, other)
object.__or__(self, other)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
757 次 |
| 最近记录: |