[英]the opposite of __add__?
在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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.