一、数字数据类型

Python的数字数据类型用于存储数值,它是不可变的数据类型,这意味着改变数字数据类型,则需要一个新分配的对象;

Python支持四种不同的数值类型:

  • 整型(Int):通常被称为是整型或整数,是正或负整数,不带小数点;

  • 长整型(long integers):无限大小的整数,整数最后是一个大写或小写的L;

  • 浮点型(floating point real values):浮点型由整数部分与小数部分组成,浮点型也可以使用科学计数法表示(2.5e2 = 2.5 x 102 = 250);

  • 复数(complex numbers):复数由实数部分和虚数部分构成,可以用a + bj,或者complex(a,b)表示, 复数的实部a和虚部b都是浮点型;

注:在Python 3里,只有一种整数类型int,表示为长整型,没有python2中的Long类型;

例如:

intlongfloatcomplex
1051924361L03.14j
100-0x19323L15.245.j
-7860122L-21.99.322e-36j
800xDEFABCECBDAECBFBAEl32.3+e18.876j
-490535633629843L-90-.6545+0J
-0x260-052318172735L-3.25E+1013e+26J
0x69-4721885298529L70.2-E124.53e-7j

长整型也可以使用小写"l",但是还是建议您使用大写"L",避免与数字"1"混淆。因此,还是使用"L"来显示长整型;

复数由实数部分和虚数部分构成,可以用a + bj,或者complex(a,b)表示, 复数的实部a和虚部b都是浮点型;

在Python中整型(int)最常用,在32位机器上,整数的位数为32位,取值范围为-2**31~2**31-1,即-2147483648~2147483647;在64位系统上,整数的位数为64位,取值范围为-2**63~2**63-1,即-9223372036854775808~9223372036854775807;

二、int的函数说明(部分函数Python2特有,Python3已删除,部分函数Python3新增;

class int(object):
    """
    int(x=0) -> int or long
    int(x=0) -> integer (Python3)
    
    Python2和Python3的用法一致,在Python2中,主要将数字或字符串转换为整数,如果没有给出参数,则返回0;如果x是浮点数,则先截断小数点在进行转换;如果x在整数范围之外,函数将返回long;
    在Python3中,主要将一个数字或字符串转换为整数,如果没有参数,返回0;如果x是一个数,返回X __int__();如果x是浮点数,则先截断小数点在进行转换;
    例如(python2):
    >>> int()
    0
    >>> int(1.9)
    1
    >>> int(2**63)
    9223372036854775808L
    >>> int(x = 0)
    0
    >>> int(x = 1.9)
    1
    >>> int(x = 2**63)
    9223372036854775808L
    
    例如(python3):
    >>> int()
    0
    >>> int(1.9)
    1
    >>> int(2**63)
    9223372036854775808
    >>> int(x = 0)
    0
    >>> int(x = 1.9)
    1
    >>> int(x = 2**63)
    9223372036854775808
    int(x, base=10) -> int or long
    int(x, base=10) -> integer
    
    Python2和Python3的用法一致,主要将浮点数或数字字符串转换为整数,如果参数x不是一个数字,必须是字符串、数组bytes或bytearray类型,可以在x可以在前面加上“+”或“-”来表示正数及负数;base参数必须是整数,表示字符串参数的进制,有效值为0和2-36,默认10就是表示使用十进制。当它是2时,表示二进制的字符串转换。当它是8时,表示是八进制的字符串转换。当它是16时,表示是十六进制的字符串转换。当它是0时,它表示不是0进制,而是按照十进制进行转换;
    例如:
    >>> int('100',base = 2)
    4
    >>> int('100',base = 0)
    100
    >>> int('100',base = 8)
    64
    >>> int('100',base = 10)
    100
    >>> int('a',base = 10)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: invalid literal for int() with base 10: 'a'
    不是数字字符串会产生报错;
    >>> int('-100',base = 8)
    -64
    >>> int('+100',base = 8)
    64
    """
    def bit_length(self): # real signature unknown; restored from __doc__
        """
        int.bit_length() -> int
        
        返回表示该数字的时占用的最少位数;
        例如:
        >>> int(10)
        10
        >>> (10).bit_length()
        4
        >>> bin(10)
        '0b1010'
        """
        return 0
    def conjugate(self, *args, **kwargs): # real signature unknown
        """ 返回该复数的共轭复数; """
        pass
    def from_bytes(cls, bytes, byteorder, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ 
        """
        int.from_bytes(bytes, byteorder, *, signed=False) -> int (Python3新增)
        
        返回给定的字节数组所表示的整数;
        
        bytes参数必须是一个类似字节的对象(例如字节或bytearray);
        byteorder参数确定用于表示整数的字节顺序。如果字节序是'big',最高有效字节排在在字节数组最开始。如果字节序是'little',则最高有效字节排在字节数组的结尾。如果要要求按照主机系统的本地字节顺序排序,则需使用'sys.byteorder'作为字节顺序值;
        signed参数指示是否使用二进制补码表示整数;
        例如:
        >>> int.from_bytes(b'\x00\x10', byteorder='big')
        16
        >>> int.from_bytes(b'\x00\x10', byteorder='little')
        4096
        >>> int.from_bytes(b'\xfc\x00', byteorder='big', signed=True)
        -1024
        >>> int.from_bytes(b'\xfc\x00', byteorder='big', signed=False)
        64512
        >>> int.from_bytes([255, 0, 0], byteorder='big')
        16711680
        """
        pass
    def to_bytes(self, length, byteorder, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ 
        """
        int.to_bytes(length, byteorder, *, signed=False) -> bytes (Python3新增)
        
        返回一个表示整数的字节数组;
        
        用字节长度表示整数。如果整数不能用给定的字节数表示,则会引发OverflowError;
        
        byteorder参数确定用于表示整数的字节顺序。如果字节序是'big',最高有效字节排在在字节数组最开始。如果字节序是'little',则最高有效字节排在字节数组的结尾。如果要要求按照主机系统的本地字节顺序排序,则需使用'sys.byteorder'作为字节顺序值;
        signed参数确定是否使用二进制补码表示整数。如果signed是False,并给出一个负整数,则会引发一个OverflowError。 signed的默认值为False;
        例如:
        >>> (1024).to_bytes(2, byteorder='big')
        b'\x04\x00'
        >>> (1024).to_bytes(10, byteorder='big')
        b'\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00'
        >>> (-1024).to_bytes(10, byteorder='big', signed=True)
        b'\xff\xff\xff\xff\xff\xff\xff\xff\xfc\x00'
        >>> x = 1000
        >>> x.to_bytes((x.bit_length() + 7) // 8, byteorder='little')
        b'\xe8\x03
        >>> (-1024).to_bytes(10, byteorder='big')
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        OverflowError: can't convert negative int to unsigned
        """
        pass
    def __abs__(self): # real signature unknown; restored from __doc__
        """ 
        x.__abs__() 等同于 abs(x) 
        
        返回绝对值,参数可以是:负数、正数、浮点数或者长×××;
        例如:
        >>> x = -2
        >>> x.__abs__()
        2
        >>> abs(x)
        2
        """
        pass
    def __add__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__add__(y) 等同于 x+y 
        加法;
        例如:
        >>> x = 2
        >>> y = 4
        >>> x.__add__(y)
        6
        >>> x + y
        6                
        """
        pass
    def __and__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__and__(y) 等同于 x&y 
        按位与;
        例如:
        >>> x = 60
        >>> y = 13
        >>> bin(x)
        '0b111100'
        >>> bin(y)
        '0b1101'
        >>> x.__and__(y)
        12
        >>> x & y
        12
        """
        pass
    def __cmp__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__cmp__(y) <==> cmp(x,y) (Python2特有,Python3已删除) 
        比较两个对象x和y,如果x < y ,返回负数;x == y, 返回0;x > y,返回正数;
        例如:
        >>> x = 10
        >>> y = 20
        >>> x.__cmp__(y)
        -1
        >>> y.__cmp__(x)
        1
        >>> cmp(x,y)
        -1
        >>> cmp(y,x)
        1
        >>> y = 10
        >>> x.__cmp__(y)
        0
        >>> cmp(x,y)
        0
        """
        pass
    def __coerce__(self, y): # real signature unknown; restored from __doc__
        """
        x.__coerce__(y) <==> coerce(x, y) (Python2特有,Python3已删除) 
        强制生成一个元组;
        例如:
        >>> x = 10
        >>> y = 20
        >>> x.__coerce__(y)
        (10, 20)
        >>> coerce(x,y)
        (10, 20)
        """
        pass
    def __bool__(self, *args, **kwargs): # real signature unknown
        """
        self != 0 (Python3新增)  
        布尔型判断;
        例如:
        >>> a = True
        >>> b = False
        >>> a.__bool__()
        True
        >>> b.__bool__()
        False
        >>> x = 0
        >>> b = x > 1
        >>> b.__bool__()
        False    
        """
        pass
    def __ceil__(self, *args, **kwargs): # real signature unknown
        """ 
        返回数字的上入整数,如果数值是小数,则返回的数值是整数加一,配合math函数使用; (Python3新增)
        例如:
        >>> import math
        >>> math.ceil(4.1)
        5 
        """
    def __divmod__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__divmod__(y) 等同于 divmod(x, y)
        数字相除,将商和余数返回一个数组,相当于 x//y ,返回(商,余数)
        例如:
        >>> x = 10
        >>> y = 11
        >>> x.__divmod__(y)
        (0, 10)
        >>> divmod(x,y)
        (0, 10)
        """
        pass
    def __div__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__div__(y) 等同于 x/y (Python2特有,Python3已删除)
 
        数字相除,返回商;
        例如:
        >>> x = 10
        >>> y = 9
        >>> x.__div__(y)
        1
        >>> div(x,y)
        >>> x / y
        1
        """
        pass
    def __eq__(self, *args, **kwargs): # real signature unknown
        """ 
        Return self==value. (Python3新增)   
        用于判断数值是否相等,返回布尔值,等价于 x == y;
        例如:
        >>> x = 10
        >>> y = 11
        >>> x.__eq__(y)
        False
        >>> z = 10
        >>> x.__eq__(z)
        True
        """
        pass
    def __float__(self): # real signature unknown; restored from __doc__
        """ 
        x.__float__() <==> float(x) 
        转换为浮点类型,即小数型;
        例如:
        >>> x = 1.4
        >>> x.__float__()
        1.4
        >>> float(x)
        1.4
        >>> y = 2
        >>> y.__float__()
        2.0
        >>> float(y)
        2.0
        """
        pass
    def __floordiv__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__floordiv__(y) 等同于 x//y 
        用于数字相除取其商,例如, 4//3 返回 1;
        例如:
        >>> x = 9
        >>> y = 7
        >>> x.__floordiv__(y)
        1
        >>> x // y
        1
        """
        pass
    def __floor__(self, *args, **kwargs): # real signature unknown
        """ 
        Flooring an Integral returns itself. (Python3新增)
  
        返回数字的下舍整数,配合math函数使用;
        例如:
        >>> import math
        >>> x = 1.54
        >>> math.floor(x)
        1
        """
        pass
    def __format__(self, *args, **kwargs): # real signature unknown
        """
        无意义;
        """
        pass
    def __getattribute__(self, name): # real signature unknown; restored from __doc__
        """ 
        x.__getattribute__('name') 等同于 x.name 
        """
        pass
    def __getnewargs__(self, *args, **kwargs): # real signature unknown
        """
        内部调用 __new__方法或创建对象时传入参数使用;
        """
        pass
    def __ge__(self, *args, **kwargs): # real signature unknown
        """ 
        Return self>=value. (Python3新增)   
        数字判断大于等于,相当于 x >= y,返回布尔值;
        例如:
        >>> x = 4
        >>> y = 4
        >>> x.__ge__(y)
        True
        >>> x >= y
        True
        >>> x = 5
        >>> x.__ge__(y)
        True
        >>> x >= y
        True
        >>> y = 7
        >>> x.__ge__(y)
        False
        >>> x >= y
        False
        """
        pass
    def __gt__(self, *args, **kwargs): # real signature unknown
        """ 
        Return self>value. (Python3新增) 
  
        数字大于判断,相当于 x > y,返回布尔值;
        例如:
        >>> x = 10
        >>> y = 9
        >>> x.__gt__(y)
        True
        >>> y.__gt__(x)
        False
        >>> x > y
        True
        >>> y < x
        False
        >>> x = 4
        >>> y = 4
        >>> x > y
        False
        >>> x.__gt__(y)
        False
        """
        pass
    def __hash__(self): # real signature unknown; restored from __doc__
        """ 
        x.__hash__() <==> hash(x) 
        如果对象object为哈希表类型,返回对象object的哈希值。哈希值为整数。在字典查找中,哈希值用于快速比较字典的键。两个数值如果相等,则哈希值也相等;
        """
        pass
    def __hex__(self): # real signature unknown; restored from __doc__
        """ 
        x.__hex__() 等同于 hex(x) 
        返回当前数的十六进制表示; (Python2特有,Python3已删除)
        例如:
        >>> x = 100
        >>> x.__hex__()
        '0x64'
        >>> hex(x)
        '0x64'
        """
        pass
    def __index__(self): # real signature unknown; restored from __doc__
        """ 
        x[y:z] <==> x[y.__index__():z.__index__()] 
        用于切片,数字无意义;
        """
        pass
    def __init__(self, x, base=10): # known special case of int.__init__
        """
        构造方法,执行 x = 123 或 x = int(10) 时,自动调用;
        """
        pass
    def __int__(self): # real signature unknown; restored from __doc__
        """ 
        x.__int__() 等同于 int(x) 
        转换为整数;
        """
        pass
    def __invert__(self): # real signature unknown; restored from __doc__
        """ 
        x.__invert__() 等同于 ~x 
        数字取反操作;
        例如:
        >>> x = 10
        >>> x.__invert__()
        -11
        >>> ~x
        -11
        """
        pass
    def __long__(self): # real signature unknown; restored from __doc__
        """ 
        x.__long__() 等同于 long(x) 
        转换为长整数; (Python2特有,Python3已删除)
        例如:
        >>> x = 10
        >>> x.__long__()
        10L
        >>> long(x)
        10L
        """
        pass
    def __le__(self, *args, **kwargs): # real signature unknown
        """ 
        Return self<=value. (Python3新增)  
        数字小于等于判断,相当于 x <= y,返回布尔值;
        例如:
        >>> x = 2
        >>> y = 4
        >>> x.__le__(y)
        True
        >>> x <= y
        True
        >>> y.__le__(x)
        False
        >>> y <= x
        False
        >>> y = 2
        >>> x.__le__(y)
        True
        >>> x <= y
        True
        """
        pass
    def __lshift__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__lshift__(y) 等同于 x<<y 
        实现一个位左移操作的功能,即x向左移动y位;
        例如:
        >>> x = 2
        >>> y = 1
        >>> bin(x)
        '0b10'
        >>> x.__lshift__(y)
        4
        >>> z = x.__lshift__(y)
        >>> bin(y)
        '0b100'
        >>> y = 2
        >>> z = x.__lshift__(y)
        >>> x.__lshift__(y)
        8
        >>> bin(z)
        '0b1000'
        """
        pass
    def __lt__(self, *args, **kwargs): # real signature unknown
        """ 
        Return self<value. 
        数字小于判断,相当于 x < y,返回布尔值; (Python3新增)
        例如:
        >>> x = 2
        >>> y = 4
        >>> x.__lt__(y)
        True
        >>> x < y
        True
        >>> y.__lt__(x)
        False
        >>> y < x
        False
        """
        pass
    def __mod__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__mod__(y) 等同于 x%y 
        实现一个“%”操作符代表的取模操作;
        例如:
        >>> x = 7
        >>> y = 3
        >>> x.__mod__(y)
        1
        >>> x % y
        1
        """
        pass
    def __mul__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__mul__(y) 等同于 x*y
 
        实现乘法;
        例如:
        >>> x = 2
        >>> y = 4
        >>> x.__mul__(y)
        8
        >>> x * y
        8
        """
        pass
    def __neg__(self): # real signature unknown; restored from __doc__
        """ 
        x.__neg__() 等同于 -x 
        数字取负操作;
        例如:
        >>> x = 3
        >>> x.__neg__()
        -3
        >>> -x
        -3
        """
        pass
    @staticmethod # known case of __new__
    def __new__(S, *more): # real signature unknown; restored from __doc__
        """ 
        T.__new__(S, ...) -> a new object with type S, a subtype of T 
        __new__方法接受的参数虽然也是和__init__一样,但__init__是在类实例创建之后调用,而__new__方法正是创建这个类实例的方法;__new__方法主要是当你继承一些不可变的class时(比如int, str, tuple),提供给你一个自定义这些类的实例化过程的途径;
        """
        pass
    def __ne__(self, *args, **kwargs): # real signature unknown
        """ 
        Return self!=value. 
        数字不相等判断,相当于x != y,返回布尔值; (Python3新增)
        例如:
        >>> x = 2
        >>> y = 4
        >>> x.__ne__(y)
        True
        >>> x != y
        True
        >>> y =2
        >>> x.__ne__(y)
        False
        >>> x != y
        False
        """
        pass
    def __nonzero__(self): # real signature unknown; restored from __doc__
        """ 
        x.__nonzero__() 等同于 x != 0 
        数字不等于0判断,相当于x != 0,返回布尔值; (Python2特有,Python3已删除)
        例如:
        >>> x = 2
        >>> x.__nonzero__()
        True
        >>> x != 0
        True
        >>> x = 0
        >>> x.__nonzero__()
        False
        >>> x != 0
        False
        """
        pass
    def __oct__(self): # real signature unknown; restored from __doc__
        """ 
        x.__oct__() 等同于 oct(x) 
        返回当前数的八进制表示; (Python2特有,Python3已删除)
        例如:
        >>> x = 17
        >>> x.__oct__()
        '021'
        >>> oct(x)
        '021'
        """
        pass
    def __or__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__or__(y) 等同于 x|y 
        按位或;
        例如:
        >>> x = 3
        >>> y = 5
        >>> bin(x)
        '0b11'
        >>> bin(y)
        '0b101'
        >>> x.__or__(y)
        7
        >>> x|y
        7
        >>> a = x.__or__(y)
        >>> bin(a)
        '0b111'
        """
        pass
    def __pos__(self): # real signature unknown; restored from __doc__
        """ 
        x.__pos__() 等同于 +x 
        数字取正操作;
        """
        pass
    def __pow__(self, y, z=None): # real signature unknown; restored from __doc__
        """ 
        x.__pow__(y[, z]) 等同于 pow(x, y[, z]) 
        幂,次方,计算x的y次方,如果z在存在,则再对结果进行取模,其结果等效于pow(x,y) %z,也可以配合math函数使用;pow()通过内置的方法直接调用,内置方法会把参数作为整型,而math模块则会把参数转换为float;
        例如:
        >>> x = 2
        >>> y = 4
        >>> pow(x,y)
        16
        >>> z = 3
        >>> pow(x,y,z)
        1
        >>> import math
        >>> math.pow(x,y)
        16.0
        """
        pass
    def __radd__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__radd__(y) 等同于 y+x 
        右加法;
        例如:
        >>> x = 2
        >>> y = 1
        >>> x.__radd__(y)
        3
        >>> y + x
        3
        """
        pass
    def __rand__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rand__(y) 等同于 y&x 
        
        按位右与;
        例如:
        >>> x = 63
        >>> y = 13
        >>> bin(x)
        '0b111111'
        >>> bin(y)
        '0b1101'
        >>> x.__rand__(y)
        13
        >>> y & x
        13
        >>> a = x.__rand__(y)
        >>> bin(a)
        '0b1101'
        >>> a = x & y
        >>> bin(a)
        '0b1101'
        """
        pass
    def __rdivmod__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rdivmod__(y) 等同于 divmod(y, x) 
        数字相除,将商和余数返回一个数组,相当于 y//x ,返回(商,余数)
        """
        pass
    def __rdiv__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rdiv__(y) 等同于 y/x 
        数字相除,返回商; (Python2特有,Python3已删除)
        """
        pass
    def __repr__(self): # real signature unknown; restored from __doc__
        """ 
        x.__repr__() 等同于 repr(x) 
        转化为解释器可读取的形式,即转换为字符串类型;
        例如:
        >>> x = 2.0
        >>> repr(x)
        '2.0'
        >>> a = repr(x)
        >>> type(a)
        <type 'str'>
        """
        pass
    def __rfloordiv__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rfloordiv__(y) 等同于 y//x 
        用于数字相除取其商;
        """
        pass
    def __rlshift__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rlshift__(y) 等同于 y<<x 
        
        实现一个位左移操作的功能,即y向左移动x位;
        例如:
        >>> x = 1
        >>> y = 2
        >>> bin(y)
        '0b10'
        >>> x.__rlshift__(y)
        4
        >>> z = x.__rlshift__(y)
        >>> bin(z)
        '0b100'
        >>> z = y << x
        >>> bin(z)
        '0b100'
        >>> x = 2
        >>> z = x.__rlshift__(y)
        >>> bin(z)
        '0b1000'
        """
        pass
    def __rmod__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rmod__(y) 等同于 y%x 
        实现一个右“%”操作符代表的取模操作;
        """
        pass
    def __rmul__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rmul__(y) 等同于 y*x 
        实现右乘法;
        """
        pass
    def __ror__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__ror__(y) 等同于 y|x 
        按位右或;
        """
        pass
    def __round__(self, *args, **kwargs): # real signature unknown
        """
        x.__rount__() 等同于 round( x [, n]  )
        返回浮点数x的四舍五入值,n参数表示保留的小数点位数; (Python3新增)
        例如:
        >>> x = 2.56
        >>> x.__round__()
        3
        >>> x.__round__(1)
        2.6
        >>> x.__round__(2)
        2.56
        >>> round(x)
        3
        >>> round(x,1)
        2.6
        >>> round(x,2)
        2.56
        """
        pass
    def __rpow__(self, x, z=None): # real signature unknown; restored from __doc__
        """ 
        y.__rpow__(x[, z]) 等同于 pow(x, y[, z]) 
        幂,次方,计算x的y次方,如果z在存在,则再对结果进行取模,其结果等效于pow(x,y) %z,也可以配合math函数使用;pow()通过内置的方法直接调用,内置方法会把参数作为整型,而math模块则会把参数转换为float;
        """
        pass
    def __rrshift__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rrshift__(y) 等同于 y>>x 
        实现一个位右移操作的功能,即y向右移动x位;
        例如:
        >>> x = 1
        >>> y = 4
        >>> bin(y)
        '0b100'
        >>> x.__rrshift__(y)
        2
        >>> z = x.__rrshift__(y)
        >>> bin(z)
        '0b10'
        >>> y >> x
        2
        >>> z = y >> x
        >>> bin(z)
        '0b10'
        """
        pass
    def __rshift__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rshift__(y) 等同于 x>>y
        实现一个位右移操作的功能,即x向右移动y位;
        例如:
        >>> x = 4
        >>> y = 1
        >>> bin(x)
        '0b100'
        >>> x.__rshift__(y)
        2
        >>> z = x.__rrshift__(y)
        >>> bin(z)
        '0b10'
        >>> x >> y
        2
        >>> z = x >> y
        >>> bin(z)
        '0b10'
        """
        pass
    def __rsub__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rsub__(y) 等同于 y-x 
        右减法,相当于y减x;
        例如:
        >>> x = 4
        >>> y = 1
        >>> x.__rsub__(y)
        -3
        >>> y - x
        -3
        """
        pass
    def __rtruediv__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rtruediv__(y) 等同于 y/x 
        右除法,相当于y除以x;
        """
        pass
    def __rxor__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rxor__(y) 等同于 y^x 
        按位右异或,相当于y按x进行异或;
        """
        pass
    def __sizeof__(self, *args, **kwargs): # real signature unknown
        """ 
        返回内存中的大小(以字节为单位); (Python2存在于long函数,Python3中合并进int函数)
        """
    def __str__(self): # real signature unknown; restored from __doc__
        """ 
        x.__str__() 等同于 str(x) 
        转换为人阅读的形式,如果没有适于人阅读的解释形式的话,则返回解释器课阅读的形式,即转换为字符串类型;
        例如:
        >>> x = 1
        >>> x.__str__()
        '1'
        >>> a = x.__str__()
        >>> type(a)
        <type 'str'>
        >>> a = str(x)
        >>> type(a)
        <type 'str'>
        """
        pass
    def __sub__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__sub__(y) <==> x-y 
        减法,相当于x减y;
        """
        pass
    def __truediv__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__truediv__(y) <==> x/y 
        除法,相当于x除以y;
        """
        pass
    def __trunc__(self, *args, **kwargs): # real signature unknown
        """ 
        返回数值被截取为×××的值,在×××中无意义;
        """
        pass
    def __xor__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__xor__(y) 等同于 x^y 
        按位异或,相当于x按y进行异或;
        """
        pass
    denominator = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """
    分母,等于1;
    """
    imag = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """
    虚数,无意义;
    """
    numerator = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """
    分子,等于数字大小;
    """
    real = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """
    实数,无意义;
    """

三、long的函数说明(函数与方法与int一致,Python3已与int类型进行合并;)

class long(object):
    """
    long(x=0) -> long
    long(x, base=10) -> long
    
    Convert a number or string to a long integer, or return 0L if no arguments
    are given.  If x is floating point, the conversion truncates towards zero.
    
    If x is not a number or if base is given, then x must be a string or
    Unicode object 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)
    4L
    """
    def bit_length(self): # real signature unknown; restored from __doc__
        """
        long.bit_length() -> int or long
        
        Number of bits necessary to represent self in binary.
        >>> bin(37L)
        '0b100101'
        >>> (37L).bit_length()
        6
        """
        return 0
    def conjugate(self, *args, **kwargs): # real signature unknown
        """ Returns self, the complex conjugate of any long. """
        pass
    def __abs__(self): # real signature unknown; restored from __doc__
        """ x.__abs__() <==> abs(x) """
        pass
    def __add__(self, y): # real signature unknown; restored from __doc__
        """ x.__add__(y) <==> x+y """
        pass
    def __and__(self, y): # real signature unknown; restored from __doc__
        """ x.__and__(y) <==> x&y """
        pass
    def __cmp__(self, y): # real signature unknown; restored from __doc__
        """ x.__cmp__(y) <==> cmp(x,y) """
        pass
    def __coerce__(self, y): # real signature unknown; restored from __doc__
        """ x.__coerce__(y) <==> coerce(x, y) """
        pass
    def __divmod__(self, y): # real signature unknown; restored from __doc__
        """ x.__divmod__(y) <==> divmod(x, y) """
        pass
    def __div__(self, y): # real signature unknown; restored from __doc__
        """ x.__div__(y) <==> x/y """
        pass
    def __float__(self): # real signature unknown; restored from __doc__
        """ x.__float__() <==> float(x) """
        pass
    def __floordiv__(self, y): # real signature unknown; restored from __doc__
        """ x.__floordiv__(y) <==> x//y """
        pass
    def __format__(self, *args, **kwargs): # real signature unknown
        pass
    def __getattribute__(self, name): # real signature unknown; restored from __doc__
        """ x.__getattribute__('name') <==> x.name """
        pass
    def __getnewargs__(self, *args, **kwargs): # real signature unknown
        pass
    def __hash__(self): # real signature unknown; restored from __doc__
        """ x.__hash__() <==> hash(x) """
        pass
    def __hex__(self): # real signature unknown; restored from __doc__
        """ x.__hex__() <==> hex(x) """
        pass
    def __index__(self): # real signature unknown; restored from __doc__
        """ x[y:z] <==> x[y.__index__():z.__index__()] """
        pass
    def __init__(self, x=0): # real signature unknown; restored from __doc__
        pass
    def __int__(self): # real signature unknown; restored from __doc__
        """ x.__int__() <==> int(x) """
        pass
    def __invert__(self): # real signature unknown; restored from __doc__
        """ x.__invert__() <==> ~x """
        pass
    def __long__(self): # real signature unknown; restored from __doc__
        """ x.__long__() <==> long(x) """
        pass
    def __lshift__(self, y): # real signature unknown; restored from __doc__
        """ x.__lshift__(y) <==> x<<y """
        pass
    def __mod__(self, y): # real signature unknown; restored from __doc__
        """ x.__mod__(y) <==> x%y """
        pass
    def __mul__(self, y): # real signature unknown; restored from __doc__
        """ x.__mul__(y) <==> x*y """
        pass
    def __neg__(self): # real signature unknown; restored from __doc__
        """ x.__neg__() <==> -x """
        pass
    @staticmethod # known case of __new__
    def __new__(S, *more): # real signature unknown; restored from __doc__
        """ T.__new__(S, ...) -> a new object with type S, a subtype of T """
        pass
    def __nonzero__(self): # real signature unknown; restored from __doc__
        """ x.__nonzero__() <==> x != 0 """
        pass
    def __oct__(self): # real signature unknown; restored from __doc__
        """ x.__oct__() <==> oct(x) """
        pass
    def __or__(self, y): # real signature unknown; restored from __doc__
        """ x.__or__(y) <==> x|y """
        pass
    def __pos__(self): # real signature unknown; restored from __doc__
        """ x.__pos__() <==> +x """
        pass
    def __pow__(self, y, z=None): # real signature unknown; restored from __doc__
        """ x.__pow__(y[, z]) <==> pow(x, y[, z]) """
        pass
    def __radd__(self, y): # real signature unknown; restored from __doc__
        """ x.__radd__(y) <==> y+x """
        pass
    def __rand__(self, y): # real signature unknown; restored from __doc__
        """ x.__rand__(y) <==> y&x """
        pass
    def __rdivmod__(self, y): # real signature unknown; restored from __doc__
        """ x.__rdivmod__(y) <==> divmod(y, x) """
        pass
    def __rdiv__(self, y): # real signature unknown; restored from __doc__
        """ x.__rdiv__(y) <==> y/x """
        pass
    def __repr__(self): # real signature unknown; restored from __doc__
        """ x.__repr__() <==> repr(x) """
        pass
    def __rfloordiv__(self, y): # real signature unknown; restored from __doc__
        """ x.__rfloordiv__(y) <==> y//x """
        pass
    def __rlshift__(self, y): # real signature unknown; restored from __doc__
        """ x.__rlshift__(y) <==> y<<x """
        pass
    def __rmod__(self, y): # real signature unknown; restored from __doc__
        """ x.__rmod__(y) <==> y%x """
        pass
    def __rmul__(self, y): # real signature unknown; restored from __doc__
        """ x.__rmul__(y) <==> y*x """
        pass
    def __ror__(self, y): # real signature unknown; restored from __doc__
        """ x.__ror__(y) <==> y|x """
        pass
    def __rpow__(self, x, z=None): # real signature unknown; restored from __doc__
        """ y.__rpow__(x[, z]) <==> pow(x, y[, z]) """
        pass
    def __rrshift__(self, y): # real signature unknown; restored from __doc__
        """ x.__rrshift__(y) <==> y>>x """
        pass
    def __rshift__(self, y): # real signature unknown; restored from __doc__
        """ x.__rshift__(y) <==> x>>y """
        pass
    def __rsub__(self, y): # real signature unknown; restored from __doc__
        """ x.__rsub__(y) <==> y-x """
        pass
    def __rtruediv__(self, y): # real signature unknown; restored from __doc__
        """ x.__rtruediv__(y) <==> y/x """
        pass
    def __rxor__(self, y): # real signature unknown; restored from __doc__
        """ x.__rxor__(y) <==> y^x """
        pass
    def __sizeof__(self, *args, **kwargs): # real signature unknown
        """ Returns size in memory, in bytes """
        pass
    def __str__(self): # real signature unknown; restored from __doc__
        """ x.__str__() <==> str(x) """
        pass
    def __sub__(self, y): # real signature unknown; restored from __doc__
        """ x.__sub__(y) <==> x-y """
        pass
    def __truediv__(self, y): # real signature unknown; restored from __doc__
        """ x.__truediv__(y) <==> x/y """
        pass
    def __trunc__(self, *args, **kwargs): # real signature unknown
        """ Truncating an Integral returns itself. """
        pass
    def __xor__(self, y): # real signature unknown; restored from __doc__
        """ x.__xor__(y) <==> x^y """
        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"""

四、float的函数说明(函数与方法的使用与int类似;)

class float(object):
    """
    float(x) -> 
    将字符串或数字转换为浮点数;
    """
    def as_integer_ratio(self): # real signature unknown; restored from __doc__
        """
        float.as_integer_ratio() -> (int, int)
       
        获取值的最简化结果,返回一对整数,其比例完全等于原始浮点数,并使用正分母;在无穷大上产生OverflowError,在NaNs上产生ValueError;
        例如:        
        >>> (10.0).as_integer_ratio()
        (10, 1)
        >>> (0.0).as_integer_ratio()
        (0, 1)
        >>> (-.25).as_integer_ratio()
        (-1, 4)
        """
        pass
    def conjugate(self, *args, **kwargs): # real signature unknown
        """ 
        返回该复数的共轭复数;
        """
        pass
    def fromhex(self, string): # real signature unknown; restored from __doc__
        """
        float.fromhex(string) -> float
        
        将十六进制转换为浮点数;
        例如:
        >>> float.fromhex('0x1.ffffp10')
        2047.984375
        >>> float.fromhex('-0x1p-1074')
        -4.9406564584124654e-324
        """
        return 0.0
    def hex(self): # real signature unknown; restored from __doc__
        """
        float.hex() -> string
        
        将浮点数转换为十六进制;
        例如:
        >>> (-0.1).hex()
        '-0x1.999999999999ap-4'
        >>> 3.14159.hex()
        '0x1.921f9f01b866ep+1'
        """
        return ""
    def is_integer(self, *args, **kwargs): # real signature unknown
        """ 
        判断是不是整数,返回布尔值;
        例如:
        >>> x = 1.1
        >>> x.is_integer()
        False
        >>> x = 2.0
        >>> x.is_integer()
        True
        """
        pass
    def __abs__(self): # real signature unknown; restored from __doc__
        """ 
        x.__abs__() 等同于 abs(x) 
        返回绝对值,参数可以是:负数、正数、浮点数或者长×××;
        例如:
        >>> x = -1.1
        >>> x.__abs__()
        1.1
        >>> abs(x)
        1.1
        """
        pass
    def __add__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__add__(y) 等同于 x+y 
        """
        pass
    def __coerce__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__coerce__(y) 等同于 coerce(x, y) 
        强制生成一个元组; (Python2特有,Python3已删除) 
        例如:
        >>> x = 1.1
        >>> y = 2.2
        >>> x.__coerce__(y)
        (1.1, 2.2)
        >>> coerce(x,y)
        (1.1, 2.2)
        """
        pass
    def __bool__(self, *args, **kwargs): # real signature unknown
        """ 
        self != 0 (Python3新增) 
        布尔型判断;
        """
        pass
    def __divmod__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__divmod__(y) 等同于 divmod(x, y) 
        数字相除,将商和余数返回一个数组,相当于 x//y ,返回(商,余数);
        例如:
        >>> x = 1.1
        >>> y = 3.3
        >>> x.__divmod__(y)
        (0.0, 1.1)
        >>> divmod(x,y)
        (0.0, 1.1)
        """
        pass
    def __div__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__div__(y) 等同于 x/y(Python2特有,Python3已删除) 
        数字相除,返回商;
        """
        pass
    def __eq__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__eq__(y) 等同于 x==y 
        用于判断数值是否相等,返回布尔值,等价于 x == y;
        """
        pass
    def __float__(self): # real signature unknown; restored from __doc__
        """ 
        x.__float__() 等同于 float(x) 
        转换为浮点类型,即小数型;
        例如:
        >>> x = 2
        >>> x.__float__()
        2.0
        >>> float(x)
        2.0
        """
        pass
    def __floordiv__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__floordiv__(y) 等同于 x//y 
        用于数字相除取其商;
        """
        pass
    def __format__(self, format_spec): # real signature unknown; restored from __doc__
        """
        float.__format__(format_spec) -> string
        
        无意义;
        """
        return ""
    def __getattribute__(self, name): # real signature unknown; restored from __doc__
        """ 
        x.__getattribute__('name') 等同于 x.name 
        """
        pass
    def __getformat__(self, typestr): # real signature unknown; restored from __doc__
        """
        float.__getformat__(typestr) -> string
        你最好不要使用这个函数,它的主要存在Python中的的测试套件中;
        typestr参数必须是'double'和'float'类型;    
        This function returns whichever of
        'unknown', 'IEEE, big-endian' or 'IEEE, little-endian' best describes the
        format of floating point numbers used by the C type named by typestr.
        """
        return ""
    def __getnewargs__(self, *args, **kwargs): # real signature unknown
        """
        内部调用 __new__方法或创建对象时传入参数使用;
        """
        pass
    def __ge__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__ge__(y) 等同于 x>=y 
        数字判断大于等于,相当于 x >= y,返回布尔值;
        """
        pass
    def __gt__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__gt__(y) 等同于 x>y 
        数字大于判断,相当于 x > y,返回布尔值;
        """
        pass
    def __hash__(self): # real signature unknown; restored from __doc__
        """ 
        x.__hash__() 等同于 hash(x) 
        如果对象object为哈希表类型,返回对象object的哈希值。哈希值为整数。在字典查找中,哈希值用于快速比较字典的键。两个数值如果相等,则哈希值也相等;
        """
        pass
    def __init__(self, x): # real signature unknown; restored from __doc__
        """
        构造方法,执行 x = 1.1 或 x = float(1.1) 时,自动调用;
        """
        pass
    def __int__(self): # real signature unknown; restored from __doc__
        """ 
        x.__int__() 等同于 int(x) 
        转换为整数;
        """
        pass
    def __le__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__le__(y) 等同于 x<=y 
        数字小于等于判断,相当于 x <= y,返回布尔值;
        """
        pass
    def __long__(self): # real signature unknown; restored from __doc__
        """ 
        x.__long__() 等同于 long(x) 
        转换为长整数; (Python2特有,Python3已删除)
        """
        pass
    def __lt__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__lt__(y) 等同于 x<y 
        数字小于判断,相当于 x < y,返回布尔值;
        """
        pass
    def __mod__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__mod__(y) 等同于 x%y 
        实现一个“%”操作符代表的取模操作;
        """
        pass
    def __mul__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__mul__(y) 等同于 x*y 
        实现乘法;
        """
        pass
    def __neg__(self): # real signature unknown; restored from __doc__
        """ 
        x.__neg__() 等同于 -x 
        数字取负操作;
        """
        pass
    @staticmethod # known case of __new__
    def __new__(S, *more): # real signature unknown; restored from __doc__
        """ 
        T.__new__(S, ...) -> a new object with type S, a subtype of T 
        __new__方法接受的参数虽然也是和__init__一样,但__init__是在类实例创建之后调用,而__new__方法正是创建这个类实例的方法;__new__方法主要是当你继承一些不可变的class时(比如int, str, tuple),提供给你一个自定义这些类的实例化过程的途径;
        """
        pass
    def __ne__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__ne__(y) 等同于 x!=y 
        数字不相等判断,相当于x != y,返回布尔值;
        """
        pass
    def __nonzero__(self): # real signature unknown; restored from __doc__
        """ 
        x.__nonzero__() 等同于 x != 0 
        数字不等于0判断,相当于x != 0,返回布尔值; (Python2特有,Python3已删除)
        """
        pass
    def __pos__(self): # real signature unknown; restored from __doc__
        """ 
        x.__pos__() 等同于 +x 
        数字取正操作;
        """
        pass
    def __pow__(self, y, z=None): # real signature unknown; restored from __doc__
        """ 
        x.__pow__(y[, z]) 等同于 pow(x, y[, z]) 
        幂,次方,计算x的y次方,如果z在存在,则再对结果进行取模,其结果等效于pow(x,y) %z,也可以配合math函数使用;
        """
        pass
    def __radd__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__radd__(y) 等同于 y+x 
        右加法;
        """
        pass
    def __rdivmod__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rdivmod__(y) 等同于 divmod(y, x) 
        数字相除,将商和余数返回一个数组,相当于 y//x ,返回(商,余数)
        """
        pass
    def __rdiv__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rdiv__(y) 等同于 y/x 
        数字相除,返回商; (Python2特有,Python3已删除)
        """
        pass
    def __repr__(self): # real signature unknown; restored from __doc__
        """ 
        x.__repr__() 等同于 repr(x) 
        转化为解释器可读取的形式,即转换为字符串类型;
        """
        pass
    def __rfloordiv__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rfloordiv__(y) 等同于 y//x 
        用于数字相除取其商;
        """
        pass
    def __rmod__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rmod__(y) 等同于 y%x 
        实现一个右“%”操作符代表的取模操作;
        """
        pass
    def __rmul__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rmul__(y) 等同于 y*x 
        实现右乘法;
        """
        pass
    def __rpow__(self, x, z=None): # real signature unknown; restored from __doc__
        """ 
        y.__rpow__(x[, z]) 等同于 pow(x, y[, z]) 
        幂,次方,计算x的y次方,如果z在存在,则再对结果进行取模,其结果等效于pow(x,y) %z,也可以配合math函数使用;
        """
        pass
    def __rsub__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rsub__(y) 等同于 y-x 
        右减法,相当于y减x;
        """
        pass
    def __rtruediv__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__rtruediv__(y) 等同于 y/x 
        右除法,相当于y除以x;
        """
        pass
    def __setformat__(self, typestr, fmt): # real signature unknown; restored from __doc__
        """
        float.__setformat__(typestr, fmt) -> None
        
        你最好不要使用这个函数,它的主要存在Python中的的测试套件中;
        
        typestr must be 'double' or 'float'.  fmt must be one of 'unknown',
        'IEEE, big-endian' or 'IEEE, little-endian', and in addition can only be
        one of the latter two if it appears to match the underlying C reality.
        
        Override the automatic determination of C-level floating point type.
        This affects how floats are converted to and from binary strings.
        """
        pass
    def __str__(self): # real signature unknown; restored from __doc__
        """ 
        x.__str__() 等同于 str(x) 
        转换为人阅读的形式,如果没有适于人阅读的解释形式的话,则返回解释器课阅读的形式,即转换为字符串类型;
        """
        pass
    def __sub__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__sub__(y) 等同于 x-y 
        减法,相当于x减y;
        """
        pass
    def __truediv__(self, y): # real signature unknown; restored from __doc__
        """ 
        x.__truediv__(y) 等同于 x/y 
        除法,相当于x除以y;
        """
        pass
    def __trunc__(self, *args, **kwargs): # real signature unknown
        """ 
        返回0和x之间最接近x的积分,即返回数值被截取为×××的值;
        例如:
        >>> x = 1.1
        >>> x.__trunc__()
        1
        >>> x = 3.6
        >>> x.__trunc__()
        3
        """
        pass
    imag = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """
    虚数,无意义;
    """
    real = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """
    实数,无意义;
    """