一、内置函数

Python内置了函数,它们按字母顺序排列如下:

内置函数
abs() delattr() help() next() slice()
all() dict() hex()
object()
sorted()
any() dir() id() oct() staticmethod()
ascii() divmod() input() open() str()
apply() enumerate() int() ord()
sum()
basestring() eval() intern() pow() super()
bin() exec() isinstance() print() tuple()
bool() execfile() issubclass() property()
type()
buffer() file() iter() range() unichr()
bytearray() filter() len() raw_input() unicode()
callable() float() list() reduce()
vars()
chr() format() locals() reload()
xrange()
classmethod() frozenset() long() repr() zip()
cmp() getattr() map() reversed() __import__()
coerce() globals() max() round()  
compile() hasattr() memoryview()
set()  
complex() hash() min() setattr()
 

黄色python3新增,标记红色python2特有,标记绿色python2特有但非通用函数;

官方链接如下:内置函数详情

各内置函数按照功能划分,可分为数学运算、集合类操作、逻辑判断、反射、IO操作、非通用、其他;

二、数学运算 

函数名

备注

abs(x)

求绝对值

1、参数可以是整型,也可以是复数

2、若参数是复数,则返回复数的模

complex([real[, imag]])

创建一个复数

divmod(a, b)

分别取商和余数

注意:整型、浮点型都可以

float([x])

将一个字符串或数转换为浮点数。如果无参数将返回0.0

int([x[, base]]) 

将一个字符转换为int类型,base表示进制

long([x[, base]]) 

将一个字符转换为long类型

pow(x, y[, z]) 

返回x的y次幂

range([start], stop[, step]) 

产生一个序列,默认从0开始

round(x[, n]) 

四舍五入

sum(iterable[, start]) 

对集合求和

oct(x)

将一个数字转化为8进制

hex(x)

将整数x转换为16进制字符串

chr(i)

返回整数i对应的ASCII字符

bin(x)

将整数x转换为二进制字符串

bool([x])

将x转换为Boolean类型

1、abs函数说明  

def abs(number): # real signature unknown; restored from __doc__
    """
    abs(number) -> number
    
    Return the absolute value of the argument.
    """
    return 0
abs

返回数字的绝对值,参数可以是整数或浮点数,如果参数是复数,则返回其大小;

例如:

>>> x = -1 

>>> abs(x) 

>>> x = 1.1 

>>> abs(x) 

1.1

2、complex函数说明 

class complex(object):
    """
    complex(real[, imag]) -> complex number
    
    Create a complex number from a real part and an optional imaginary part.
    This is equivalent to (real + imag*1j) where imag defaults to 0.
    """
    def conjugate(self): # real signature unknown; restored from __doc__
        """
        complex.conjugate() -> complex
        
        Return the complex conjugate of its argument. (3-4j).conjugate() == 3+4j.
        """
        return complex

    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 __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 __eq__(self, y): # real signature unknown; restored from __doc__
        """ x.__eq__(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): # real signature unknown; restored from __doc__
        """
        complex.__format__() -> str
        
        Convert to a string according to format_spec.
        """
        return ""

    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 __ge__(self, y): # real signature unknown; restored from __doc__
        """ x.__ge__(y) <==> x>=y """
        pass

    def __gt__(self, y): # real signature unknown; restored from __doc__
        """ x.__gt__(y) <==> x>y """
        pass

    def __hash__(self): # real signature unknown; restored from __doc__
        """ x.__hash__() <==> hash(x) """
        pass

    def __init__(self, real, imag=None): # real signature unknown; restored from __doc__
        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 """
        pass

    def __long__(self): # real signature unknown; restored from __doc__
        """ x.__long__() <==> long(x) """
        pass

    def __lt__(self, y): # real signature unknown; restored from __doc__
        """ x.__lt__(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 __ne__(self, y): # real signature unknown; restored from __doc__
        """ x.__ne__(y) <==> x!=y """
        pass

    def __nonzero__(self): # real signature unknown; restored from __doc__
        """ x.__nonzero__() <==> x != 0 """
        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 __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 __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]) """
        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 __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

    imag = property(lambda self: 0.0)
    """the imaginary part of a complex number

    :type: float
    """

    real = property(lambda self: 0.0)
    """the real part of a complex number

    :type: float
    """

complex
complex

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-28
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-19
  • 2021-09-25
  • 2022-02-06
  • 2021-05-10
相关资源
相似解决方案