当前位置: 首页 > 图文教程 > 脚本技术 > Python > python 运算符 供重载参考

Python
Python 文件操作实现代码
动态创建类实例代码
python 中文字符串的处理实现代码
Python 匹配任意字符(包括换行符)的正则表达式写法
Python 开发Activex组件方法
Python+Django在windows下的开发环境配置图解
python 文件和路径操作函数小结
python 快速排序代码
Python2.5/2.6实用教程 入门基础篇
Python3 入门教程 简单但比较不错
Python 元类使用说明

Python 中的 python 运算符 供重载参考


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-11   浏览: 215 ::
收藏到网摘: n/a

二元运算符及其对应的特殊方法
二元运算符 特殊方法
+ __add__,__radd__
- __sub__,__rsub__
* __mul__,__rmul__
/ __div__,__rdiv__,__truediv__,__rtruediv__
// __floordiv__,__rfloordiv__
% __mod__,__rmod__
** __pow__,__rpow__
<< __lshift__,__rlshift__
>> __rshift__,__rrshift__
& __and__,__rand__
^ __xor__,__rxor__
| __or__,__ror__
+= __iaddr__
-= __isub__
*= __imul__
/= __idiv__,__itruediv__
//= __ifloordiv__
%= __imod__
**= __ipow__
<<= __ilshift__
>>= __irshift__
&= __iand__
^= __ixor__
|= __ior__
== __eq__
!=,<> __ne__
> __get__
< __lt__
>= __ge__
<= __le__