博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python 的特殊方法详解
阅读量:4655 次
发布时间:2019-06-09

本文共 1247 字,大约阅读时间需要 4 分钟。

1,不具有运算功能的特殊方法:

字符串 /字节序列表示形式	__repr__、 __str__、 __format__、 __bytes__数值转换 	__abs__、 __bool__、 __complex__、 __int__、 __float__、 __hash__、 __index__集合模拟 	__len__、 __getitem__、 __setitem__、 __delitem__、 __contains__迭代枚举 	__iter__、 __reversed__、 __next__可调用模拟	__call__上下文管理	__enter__、 __exit__实例创建和销毁	__new__、 __init__、 __del__属性管理 	__getattr__、 __getattribute__、 __setattr__、 __delattr__、 __dir__属性描述符	__get__、 __set__、 __delete__跟类相关的服务	__prepare__、 __instancecheck__、 __subclasscheck__

 2,和运算符对应的特殊方法:

一 元 运 算 符	__neg__ -、 __pos__ +、 __abs__ abs()众多比较 运 算 符	__lt__ <、 __le__ <=、 __eq__ ==、 __ne__ !=、 __gt__ >、 __ge__ >=算 术 运 算 符	"__add__ +、 __sub__ -、 __mul__ *、 __truediv__ /、 __floordiv__ //、 __mod__ %、 __divmod__divmod()、 __pow__ ** 或pow()、 __round__ round()"反 向 算 术 运 算 符	__radd__、 __rsub__、 __rmul__、 __rtruediv__、 __rfloordiv__、 __rmod__、 __rdivmod__、__rpow__增 量 赋 值 算 术 运 算 符	__iadd__、 __isub__、 __imul__、 __itruediv__、 __ifloordiv__、 __imod__、 __ipow__位 运 算 符	__invert__ ~、 __lshift__ <<、 __rshift__ >>、 __and__ &、 __or__ |、 __xor__ ^反 向 位 运 算 符	__rlshift__、 __rrshift__、 __rand__、 __rxor__、 __ror__增 量 赋 值 位 运 算 符	__ilshift__、 __irshift__、 __iand__、 __ixor__、 __ior__

 3,运算符特殊方法的详细说明:

 

转载于:https://www.cnblogs.com/zhanghu-leo/p/python.html

你可能感兴趣的文章
ViewPager和View组合 实现页面的切换
查看>>
使用PagerSlidingTabStrip实现顶部导航栏
查看>>
调用摄像头和相册
查看>>
jQuery.事件对象
查看>>
CSS之属相相关
查看>>
整理了一下自己买过的计算机书
查看>>
解决py2exe error: MSVCP90.dll: No such file or directory
查看>>
java RSA实现私钥签名、公钥验签、私钥加密数据、公钥解密数据
查看>>
Erlang 练习题
查看>>
数据挖掘十大算法总结--核心思想,算法优缺点,应用领域
查看>>
GDALWarp设置GDALWarpOptions::dfWarpMemoryLimit过大时处理失败
查看>>
libubox组件(2)——blob/blobmsg (转载 https://segmentfault.com/a/1190000002391970)
查看>>
建立RSA协商加密的安全信道
查看>>
博客园的手机版(非官方) MVC+jQuery.Mobile
查看>>
jmeter在linux上运行
查看>>
js 逻辑与 逻辑或
查看>>
“请求/响应”模型
查看>>
【坑】重写一个vector
查看>>
【UOJ 55】志愿者选拔
查看>>
Python -- pandas
查看>>