设为首页 收藏本站
查看: 1035|回复: 0

[经验分享] Python基本数据类型(一)

[复制链接]

尚未签到

发表于 2018-8-11 10:55:15 | 显示全部楼层 |阅读模式
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
  
    """
  
    实数,无意义;
  
    """

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-550060-1-1.html 上篇帖子: Python: 什么是*args和**kwargs 下篇帖子: python 列表生成、元组、字典
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表