int内部功能介绍

int内部功能详解:

class int(object):
    """
    int(x=0) -> integer
    int(x, base=10) -> integer

    Convert a number or string to an integer, or return 0 if no arguments
    are given.  If x is a number, return x.__int__().  For floating point
    numbers, this truncates towards zero.

    If x is not a number or if base is given, then x must be a string,
    bytes, or bytearray instance representing an integer literal in the
    given base.  The literal can be preceded by ‘+‘ or ‘-‘ and be surrounded
    by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
    Base 0 means to interpret the base from the string as an integer literal.
    >>> int(‘0b100‘, base=0)
    4
    """

    def bit_length(self):  # real signature unknown; restored from __doc__
        """
        int.bit_length() -> int

        Number of bits necessary to represent self in binary.
        >>> bin(37)
        ‘0b100101‘
        >>> (37).bit_length()
        6
        """
        return 0
        """ 返回表示该数字的时占用的最少位数 """

    def conjugate(self, *args, **kwargs):  # real signature unknown
        """ Returns self, the complex conjugate of any int. """
        pass
        """ 返回该复数的共轭复数 """

    def __abs__(self, *args, **kwargs):  # real signature unknown
        """ abs(self) """
        pass
        """绝对值
        >>> a = -14
        >>> a.__abs__()
        14
        >>> abs(a) 这种方法实现背后也是调用__abs__()方法
        14"""

    def __add__(self, *args, **kwargs):  # real signature unknown
        """ Return self+value. """
        pass

    def __and__(self, *args, **kwargs):  # real signature unknown
        """ Return self&value. """
        pass

    def __bool__(self, *args, **kwargs):  # real signature unknown
        """ self != 0 """
        pass

    def __ceil__(self, *args, **kwargs):  # real signature unknown
        """ Ceiling of an Integral returns itself. """
        pass

    def __divmod__(self, *args, **kwargs):  # real signature unknown
        """ Return divmod(self, value). """
        pass
        """    相除,得到商(self)和余数(value)组成的元组
               网页中显示分页的时候使用,
           >>> age = 18
        >>> age.__divmod__(7)
        (2, 4)
        """

    def __eq__(self, *args, **kwargs):  # real signature unknown
        """ Return self==value. """
        pass

    def __float__(self, *args, **kwargs):  # real signature unknown
        """ float(self) """
        pass
        """转换为浮点类型
        >>> a = int(16)
        >>> b = a.__float__()
        >>> type(a)
        <class ‘int‘>
        >>> type(b)
        <class ‘float‘>
        """

    def __floordiv__(self, *args, **kwargs):  # real signature unknown
        """ Return self//value. """
        pass
        """地板除
        >>> a = 13
        >>> b = 4
        >>> a//b
        3
        >>> a.__floordiv__(b)
        3
        """

    def __floor__(self, *args, **kwargs):  # real signature unknown
        """ Flooring an Integral returns itself. """
        pass

    def __getattribute__(self, *args, **kwargs):  # real signature unknown
        """ Return getattr(self, name). """
        pass

    def __getnewargs__(self, *args, **kwargs):  # real signature unknown
        pass
        """ 内部调用 __new__方法或创建对象时传入参数使用 """

    def __ge__(self, *args, **kwargs):  # real signature unknown
        """ Return self>=value. """
        pass

    def __gt__(self, *args, **kwargs):  # real signature unknown
        """ Return self>value. """
        pass

    def __hash__(self, *args, **kwargs):  # real signature unknown
        """ Return hash(self). """
        pass
        """如果对象object为哈希表类型,返回对象object的哈希值。哈希值为整数。在字典查找中,哈希值用于快速比较字典的键。两个数值如果相等,则哈希值也相等。"""

    def __index__(self, *args, **kwargs):  # real signature unknown
        """ Return self converted to an integer, if self is suitable for use as an index into a list. """
        pass

    def __init__(self, x, base=10):  # known special case of int.__init__

        """
        int(x=0) -> integer
        int(x, base=10) -> integer

        Convert a number or string to an integer, or return 0 if no arguments
        are given.  If x is a number, return x.__int__().  For floating point
        numbers, this truncates towards zero.

        If x is not a number or if base is given, then x must be a string,
        bytes, or bytearray instance representing an integer literal in the
        given base.  The literal can be preceded by ‘+‘ or ‘-‘ and be surrounded
        by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
        Base 0 means to interpret the base from the string as an integer literal.
        >>> int(‘0b100‘, base=0)
        4
        # (copied from class doc)
        """
        pass
        """构造方法,执行 x = 123 或 x = int(10) 时,自动调用"""

    def __int__(self, *args, **kwargs):  # real signature unknown
        """ int(self) """
        pass
        """转换为整数
        >>> a = 18.2
        >>> a.__int__()
        18
        """
    def __invert__(self, *args, **kwargs):  # real signature unknown
        """ ~self """
        pass

    def __le__(self, *args, **kwargs):  # real signature unknown
        """ Return self<=value. """
        pass

    def __lshift__(self, *args, **kwargs):  # real signature unknown
        """ Return self<<value. """
        pass

    def __lt__(self, *args, **kwargs):  # real signature unknown
        """ Return self<value. """
        pass

    def __mod__(self, *args, **kwargs):  # real signature unknown
        """ Return self%value. """
        pass

    def __mul__(self, *args, **kwargs):  # real signature unknown
        """ Return self*value. """
        pass

    def __neg__(self, *args, **kwargs):  # real signature unknown
        """ -self """
        pass

    @staticmethod  # known case of __new__
    def __new__(*args, **kwargs):  # real signature unknown
        """ Create and return a new object.  See help(type) for accurate signature. """
        pass

    def __ne__(self, *args, **kwargs):  # real signature unknown
        """ Return self!=value. """
        pass

    def __or__(self, *args, **kwargs):  # real signature unknown
        """ Return self|value. """
        pass

    def __pos__(self, *args, **kwargs):  # real signature unknown
        """ +self """
        pass

    def __pow__(self, *args, **kwargs):  # real signature unknown
        """ Return pow(self, value, mod). """
        pass
        """幂,次方
        >>> a = 3
        >>> c = a.__pow__(3)
        >>> c
        27
        >>> b = a * a * a
        >>> b
        27
        """

        # 例如:__radd__中的r代表从右往左执行
    def __radd__(self, *args, **kwargs):  # real signature unknown
        """ Return value+self. """
        pass

    def __rand__(self, *args, **kwargs):  # real signature unknown
        """ Return value&self. """
        pass

    def __rdivmod__(self, *args, **kwargs):  # real signature unknown
        """ Return divmod(value, self). """
        pass

    def __repr__(self, *args, **kwargs):  # real signature unknown
        """ Return repr(self). """
        pass
        """转化为解释器可读取的形式 """

    def __rfloordiv__(self, *args, **kwargs):  # real signature unknown
        """ Return value//self. """
        pass

    def __rlshift__(self, *args, **kwargs):  # real signature unknown
        """ Return value<<self. """
        pass

    def __rmod__(self, *args, **kwargs):  # real signature unknown
        """ Return value%self. """
        pass

    def __rmul__(self, *args, **kwargs):  # real signature unknown
        """ Return value*self. """
        pass

    def __ror__(self, *args, **kwargs):  # real signature unknown
        """ Return value|self. """
        pass

    def __round__(self, *args, **kwargs):  # real signature unknown
        """
        Rounding an Integral returns itself.
        Rounding with an ndigits argument also returns an integer.
        """
        pass

    def __rpow__(self, *args, **kwargs):  # real signature unknown
        """ Return pow(value, self, mod). """
        pass

    def __rrshift__(self, *args, **kwargs):  # real signature unknown
        """ Return value>>self. """
        pass

    def __rshift__(self, *args, **kwargs):  # real signature unknown
        """ Return self>>value. """
        pass

    def __rsub__(self, *args, **kwargs):  # real signature unknown
        """ Return value-self. """
        pass

    def __rtruediv__(self, *args, **kwargs):  # real signature unknown
        """ Return value/self. """
        pass

    def __rxor__(self, *args, **kwargs):  # real signature unknown
        """ Return value^self. """
        pass
        # 例如:__radd__中的r代表从右往左执行

    def __sizeof__(self, *args, **kwargs):  # real signature unknown
        """ Returns size in memory, in bytes """
        pass

    def __str__(self, *args, **kwargs):  # real signature unknown
        """ Return str(self). """
        pass
        """转换为人阅读的形式,如果没有适于人阅读的解释形式的话,则返回解释器课阅读的形式"""

    def __sub__(self, *args, **kwargs):  # real signature unknown
        """ Return self-value. """
        pass

    def __truediv__(self, *args, **kwargs):  # real signature unknown
        """ Return self/value. """
        pass

    def __trunc__(self, *args, **kwargs):  # real signature unknown
        """ Truncating an Integral returns itself. """
        pass
        """ 返回数值被截取为整形的值,在整形中无意义 """

    def __xor__(self, *args, **kwargs):  # real signature unknown
        """ Return self^value. """
        pass

    denominator = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """the denominator of a rational number in lowest terms"""

    imag = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """the imaginary part of a complex number"""
    """ 虚数,无意义 """

    numerator = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """the numerator of a rational number in lowest terms"""
    """ 分子 = 数字大小 """

    real = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """the real part of a complex number"""
    """ 实属,无意义 """
时间: 2024-10-13 20:22:23

int内部功能介绍的相关文章

Python之int内部功能介绍

int内部功能的介绍 通过dir(int类型的值)或者使用开发工具Ctrl+单击"int"即可查看int内部的所有功能.内部功能很多,但是很多的内部功能都不怎么常用,特介绍如下常用到的一些内部功能 type() 1.基本数据类型使用type()函数时,得到相应的数据类型a = 12b = 12.01c = "123"print(type(a)) >>> intprint(type(b)) >>> floatprint(type(c

python里int内部功能介绍

bit_length()   #用二进制数表示10进制数时,二进制的最少的位数(长度) 列如: 2用二进制表示为 00000010 10    使用bit_ength()就表示长度为1位,它会把前面的0自动省略掉 bin(2)   用二进制表示2 列如 bin(2) 0b10    0b表示二进制 __abs__    取绝对值 列如:取三的绝对值 a=-3 a.__abs__() 3 在python中带下划线的表示内置函数 内置函数的使用可以通过对象或者直接调用 列如: 对象,直接去执行这个方

python中int的功能介绍

int的功能介绍 1. 绝对值 x.__abs__()等同于abs(x) 2. 加法 x.__add__(y)等同于x+y 3. 与运算 x.__and__(y)等同于x&y 4. 布尔运算 x.__bool__() 5. 商和余数 x.__divmod__(y)等同于divmod(x,y) 6. 等于 x.__eq__(y)等同于x==y 7. 整数转为为浮点数 x.__float__()等同于float(x) 8. 地板除 x.__floordiv__(y)等同于x//y 9. 大于等于 x

python int 内部功能剖析

在python中,一切都是对象!对象由类创建而来,对象所拥有的功能都来自于类.在本节中,我们了解一下int类型对象具有哪些功能,我们平常是怎么使用的. int 类源码分析 class int(object): """ int(x=0) -> int or long int(x, base=10) -> int or long Convert a number or string to an integer, or return 0 if no arguments

python 3.5 (内部功能介绍)

int整性类 class int(object): """ int(x=0) -> int or long int(x, base=10) -> int or long Convert a number or string to an integer, or return 0 if no arguments are given. If x is floating point, the conversion truncates towards zero. If x

python里list列表,tuple元组内部功能介绍

list列表 append            #在列表尾部追加元素 clear                #把列表清空 count               #统计元素出现的次数 extend             #合并两个列表或者元组与列表合并,对原来列表的扩展 index                #获取元素的下标,索引 insert                #插入元素,可以自己指定插入位置 pop                   #删除某个元素,默认删除最后一个

Python str内部功能介绍

def capitalize(self): str = 'aGe'print(str.capitalize())结果:Age结论:首字母大写,其他字母都小写 def casefold(self): str = 'AGE-age'print(str.casefold()) 结果:age-age结论:首字母大写,其他字母都小写 def center(self, width, fillchar=None): str = 'AGE-age'print(str.center(20,'='))结果:====

C#中system.object的函数方法功能介绍-转载

C#中system.object的函数方法功能介绍 在C#中,Object类型是所有类型的根,大家平常开发中都要跟它打交道,但不见得对它里面的每个方法都知根知底,下面对它里面的每个方法都进行仔细的总结. 概述: 构造函数 Equals函数 Finalize函数 GetHashCode函数 GetType()函数 ReferenceEquals函数 MemberWiseClone()函数 ToString()函数 Object类型中一共有8个方法,重载的方法没有算进来.下面一一来看看这些方法. 1

Exchange2016正式版功能介绍及全新安装配置

Exchange2016功能介绍及全新安装配置 说到Exchange服务相信很多人都在关注,微软在2015年更新了很多服务,从功能上来说确实做了很多优化及提升,具体就不多说了,微软在2015年10月1日发布了Exchange2016正式版,版本还是分为标准版和企业版,此次发布为多语言版本 同样微软在2015年发布了那些新产品呢 : 我们还是说说Exchange2016,从安装及官网文档上看微软从Exchange2010到Exchange2016角色上缩减了很多,从Exchange2010的Mai