登录

python里的双下划线函数都是什么意思?

__module__
__new__
__reduce__
__repr__
__reduce_ex__
__getattribute__
# Python
ringa_leeringa_lee2146 天前649 次浏览

全部回复(4) 我要回复

  • 怪我咯

    怪我咯2017-04-17 17:39:23

    看这里

    回复
    0
  • 天蓬老师

    天蓬老师2017-04-17 17:39:23

    http://rafekettler.com/magicmethods.html

    回复
    0
  • 大家讲道理

    大家讲道理2017-04-17 17:39:23

    隐藏属性,或者隐藏方法。

    比如

    >>> '33'.__hash__()
    4038753864587545164
    >>> '33'.__len__()==len('33')
    True
    
    
    >>> (3).__pow__(2)
    9
    
    >>> int.__pow__(3,2)
    9

    回复
    0
  • 大家讲道理

    大家讲道理2017-04-17 17:39:23

    简单的说,就是hook。

    回复
    0
  • 取消回复发送