簡體   English   中英

__add__的反義詞?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM