一 基本数据类型

python  学习之数据类型和for循环

 

比如数字来说:

  数字的方法都放在int类中,而数字是类的实例化。 如上图所示

1,整型

python  学习之数据类型和for循环
n1=4
n2=4
print(n1.__add__(n2))

a=18
print("the num 18 's bit is:",a.bit_length())
python  学习之数据类型和for循环
 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

@classmethod # known case
def from_bytes(cls, bytes, byteorder, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ 
    """
    int.from_bytes(bytes, byteorder, *, signed=False) -> int
    
    Return the integer represented by the given array of bytes.
    
    The bytes argument must be a bytes-like object (e.g. bytes or bytearray).
    
    The byteorder argument determines the byte order used to represent the
    integer.  If byteorder is 'big', the most significant byte is at the
    beginning of the byte array.  If byteorder is 'little', the most
    significant byte is at the end of the byte array.  To request the native
    byte order of the host system, use `sys.byteorder' as the byte order value.
    
    The signed keyword-only argument indicates whether two's complement is
    used to represent the integer.
    """
    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
    
    Return an array of bytes representing an integer.
    
    The integer is represented using length bytes.  An OverflowError is
    raised if the integer is not representable with the given number of
    bytes.
    
    The byteorder argument determines the byte order used to represent the
    integer.  If byteorder is 'big', the most significant byte is at the
    beginning of the byte array.  If byteorder is 'little', the most
    significant byte is at the end of the byte array.  To request the native
    byte order of the host system, use `sys.byteorder' as the byte order value.
    
    The signed keyword-only argument determines whether two's complement is
    used to represent the integer.  If signed is False and a negative integer
    is given, an OverflowError is raised.
    """
    pass

def __abs__(self, *args, **kwargs): # real signature unknown
""" 返回绝对值 """

    """ abs(self) """
    pass

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

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

def __float__(self, *args, **kwargs): # real signature unknown
    """
转换为浮点类型
float(self) """
    pass

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

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

def __format__(self, *args, **kwargs): # real signature unknown
    pass

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

def __getnewargs__(self, *args, **kwargs): # real signature unknown
    pass

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

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

def __int__(self, *args, **kwargs): # real signature unknown
    """ int(self) """
    pass

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

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

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"""
View Code

相关文章:

  • 2021-05-15
  • 2021-11-04
  • 2021-11-20
  • 2021-08-19
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
猜你喜欢
  • 2021-06-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案