python built-in functions

abs ( x )

Return the absolute value of a number. The argument may be a plain or long integer or a floating point number. If the argument is a complex number, its magnitude is returned.

all ( iterable )

Return True if all elements of the iterable are true (or if the iterable is empty).

any ( iterable )

Return True if any element of the iterable is true. If the iterable is empty, return False.

basestring ( )

This abstract type is the superclass for str and unicode. It cannot be called or instantiated, but it can be used to test whether an object is an instance of str orunicode. isinstance(obj,basestring) is equivalent to isinstance(obj,(str,unicode)).

bin ( x )

Convert an integer number to a binary string. The result is a valid Python expression. If x is not a Python int object, it has to define an __index__() method that returns an integer.

bool ( [ x ] )

Convert a value to a Boolean, using the standard truth testing procedure. If x is false or omitted, this returns False; otherwise it returns True. bool is also a class, which is a subclass of int. Class bool cannot be subclassed further. Its only instances areFalse and True.

bytearray ( [ source [, encoding [, errors ] ] ] )

Return a new array of bytes. The bytearray type is a mutable sequence of integers in the range 0 <= x < 256. It has most of the usual methods of mutable sequences, described in Mutable Sequence Types, as well as most methods that the str type has, see String Methods.

The optional source parameter can be used to initialize the array in a few different ways:

  • If it is a string, you must also give the encoding (and optionally, errors) parameters; bytearray() then converts the string to bytes using str.encode().

  • If it is an integer, the array will have that size and will be initialized with null bytes.

  • If it is an object conforming to the buffer interface, a read-only buffer of the object will be used to initialize the bytes array.

  • If it is an iterable, it must be an iterable of integers in the range 0<=x<256, which are used as the initial contents of the array.

Without an argument, an array of size 0 is created.























你可能感兴趣的:(python,functions,built-in)