操作符重载的魔术方法
操作符 |
方法 |
取反 |
即席 |
+ |
__add__ |
__radd__ |
__iadd__ |
- |
__sub__ |
__rsub__ |
__isub__ |
* |
__mul__ |
__rmul__ |
__imul__ |
/ |
__truediv__ |
__rtruediv__ |
__itruediv__ |
// |
__floordiv__ |
__rfloordiv__ |
__ifloordiv__ |
% |
__mod__ |
__rmod__ |
__imod__ |
** |
__pow__ |
__rpow__ |
__ipow__ |
& |
__and__ |
__rand__ |
__iand__ |
| |
__or__ |
__ror__ |
__ior__ |
^ |
__xor__ |
__rxor__ |
__ixor__ |
<< |
__lshift__ |
__rlshift__ |
__ilshift__ |
>> |
__rshift__ |
__rrshift__ |
__irshift__ |
__eq__ ==
__ne__ !=
__lt__ <
__le__ <=
__gt__ >
__ge__ >=
__contains__
__getitem__
__setitem__
__delitem__
__getattr__
__setattr__
__getarrtibute__