Python:Python运算符重载(简版)

__add__(self, other): +
__sub__(self, other): -
__mul__(self, other): *
__matmul__(self, other): @
__truediv__(self, other): /
__floordiv__(self, other): //
__mod__(self, other): %
__divmod__(self, other): divmod, divmod(a, b) = (a/b, a%b)
__pow__(self, other[,modulo]): **, pow()
__lshift__(self, other): <<
__rshift__(self, other): >>
__and__(self, other): &
__xor__(self, other): ^
__or__(self, other): |
 

你可能感兴趣的:(Python)