Vamei Source: Http://www.cnblogs.com/vamei Welcome reprint, Please also keep this statement.
The Python built-in (built-in) function is created as the Python interpreter runs. In Python programs, you can call these functions at any time, and you don't need to define them. The most common built-in functions are:
Print ("Hello world!")
In the Python tutorial, we have mentioned some of the following built-in functions:
Basic datatype type ()
Look back at Dir () help () Len ()
Dictionary Len ()
Input and output of text file open ()
Loop design Range () enumerate () Zip ()
Cyclic object iter ()
Function Object map () filter () reduce ()
The following are all the actual parameters, and you can try the effect directly on the command line.
Mathematical Operations
ABS ( -5) # take absolute value, i.e. 5
Round (2.6) # Rounded rounding, that is 3.0
Pow (2, 3) # equivalent to 2**3, if it is POW (2, 3, 5), equivalent to 2**3% 5
CMP (2.3, 3.2) # compares the size of a two number
Divmod (9,2) # Returns the division result and remainder
Max ([1,5,2,9]) # Ask for maximum value
MIN ([9,2,-4,2]) # to find the minimum value
SUM ([2,-1,9,12]) # sum
Type conversions
Int ("5") # is converted to an integral integer
Float (2) # Convert to floating-point float
Long ("Zero") # converts to a long integer long
STR (2.3) # Converts to string strings
Complex (3, 9) # returns complex number 3 + 9i
Ord ("a") # "a" character corresponding value
CHR # Number 65 corresponds to the character
UNICHR (+) # VALUE 65 for Unicode characters
BOOL (0) # converted to the corresponding true and False value, in Python, 0 is equivalent to False
In Python, the following objects are equivalent to false: [], (), {}, 0, None, 0.0, "
Bin (#) # Returns a String that represents the binary number of 56
Hex # Returns a String that represents the hexadecimal number of 56
Oct (dimension) # Returns a String that represents the octal number of 56
List (()) # Convert to Table list
Tuple ([2,3,4]) # Convert to Fixed value table tuple
Slice (5,2,-1) # Build Subscript Object Slice
Dict (a=1,b= "Hello", c=[1,2,3]) # Build Dictionary dictionary
Sequence Operations
All ([True, 1, "hello!"]) # If all elements are equal to true values
Any (["", 0, False, [], None]) # is there any one element equal to the true value
Sorted ([1,5,3]) # Returns the sequence of the positive sequence, i.e. [1,3,5]
Reversed ([1,5,3]) # Returns the sequence of the reverse order, i.e. [3,5,1]
class, object, property
# define Class Me (object): def"hello!" "New hello!" me = Me ()
Hasattr (Me, "test") # Check if the Me object has a test property
GetAttr (Me, "test") # Returns the Test property
SetAttr (Me, "test", New_test) # Set the test property to New_test
Delattr (Me, "test") # Delete Test Property
Isinstance (Me, Me) # Me object is the object generated by the Me class (a instance)
Issubclass (Me, object) # Me class is a subclass of the object class
compile, execute
Repr (Me) # Returns the string representation of an object
Compile ("Print (' Hello ')", ' test.py ', ' exec ') # Compile string becomes code object
Eval ("1 + 1") # interprets the string expression. The parameter can also be a code object returned by the compile ()
EXEC ("Print (' Hello ')") # interprets and executes the string, print (' Hello '). The parameter can also be a code object returned by the compile ()
other
Input ("Please input:") # Wait for input
Globals () # Returns the global namespace, such as global variable name, global function name
Locals () # Returns the local namespace
Python supplemental python built-in function list