python - 组合数据 魔法函数 操作

python/docs-pdf/library.pdf

The full list of supported magic methods is:
•__hash__,__sizeof__,__repr__and__str__
•__dir__,__format__and__subclasses__
•__round__,__floor__,__trunc__and__ceil__
•Comparisons:__lt__,__gt__,__le__,__ge__,__eq__and__ne__
•Container methods:__getitem__,__setitem__,__delitem__,
__contains__,__len__,__iter__,__reversed__and__missing__
•Context manager:__enter__,__exit__,__aenter__and__aexit__
•Unary numeric methods:__neg__,__pos__and__invert__
•The numeric methods (including right hand and in-place variants):
__add__,__sub__,__mul__,__matmul__,__div__,__truediv__,
__floordiv__,__mod__,__divmod__,__lshift__,__rshift__,
__and__,__xor__,__or__, and__pow__
•Numeric conversion methods:__complex__,__int__,__float__and__index__
•Descriptor methods:__get__,__set__and__delete__
•Pickling:__reduce__,__reduce_ex__,__getinitargs__,
__getnewargs__,__getstate__and__setstate__
•File system path representation:__fspath__
•Asynchronous iteration methods:__aiter__and__anext__
在3.8版更改: Added support foros.PathLike.__fspath__().
在3.8版更改: Added support for__aenter__,__aexit__,__aiter__and__anext__.
The following methods exist but arenotsupported as they are either in use by mock,
 can’t be set dynamically, or cancause problems:
 •__getattr__,__setattr__,__init__and__new__
 •__prepare__,__instancecheck__,__subclasscheck__,__del__

4.6序列类型—list,tuple,range
4.6.1通用序列操作
在这里插入图片描述
4.6.3可变序列类型
在这里插入图片描述
我使用help()的方法查看文档,但是有的文档漏写解释,有的干脆直接漏写函数方法,于是就取看官方文档。

例如tuple.getnewargs(self, /)的解释,tuple.sizeof(self, /)这个就没写。

In [1]: print(dir({}))
['__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值