Preface: Python's built-in function provides a great convenience for programming, which is a relatively complete summary of the built-in functions of Python 3.x in order to facilitate later learning.
A
? ABS (x):if x is a complex number, the size of it is returnedIf an integer or floating-point number returns its absolute value
1 Print (ABS ( -1)) 2 Print (ABS ( -10.01)) 3 Print #返回复数的大小
?
All (iterable):If all elements of iterable are not 0, ', false, or iterable are empty, all (iterable) returns True, otherwise false
Special attention:
(1) iterable is generally a list or tuple
1 Print (All ([1,2,-5,'agg'])) 2 Print (All ((0,', True)))
(2) Empty tuples and empty lists return true
1 Print (All ([])) # Empty list 2 Print (All (())) # Empty tuple
(3) All (iterable) is equivalent to:
1 def All (iterable): 2 for inch iterable: 3 if not element: 4 return False 5 return True
?
Any (iterable):If iterable all elements are 0, ', false, or iterable is empty, any (iterable) returns false, otherwise true
Special attention:
(1) iterable is generally a list or tuple
1 Print (Any ([0,1,2,3])) 2 Print (Any (0,', False)))
(2) empty list and empty tuple return false
1 Print (Any (())) # Empty tuple 2 Print (Any ([])) # Empty list
(3) any (iterable) is equivalent to:
1 def Any (iterable): 2 for inch iterable: 3 if element: 4 return True 5 return False
?
ASCII (objiect):Returns the string form of object
Special attention:
If the Objiect object contains non-ASCII characters, the string using \x,\u or \u encoding is returned by REPR ()
1 number=12342 name='tomwenxing'3 location=' Hangzhou '4print(ASCII (number), type (number))5 Print(ASCII (name), type (ASCII (name)))6print(location), type (ASCII ( Location)))
B?
bin (x):Returns an integer int or a long integerBinary
Representation (the string)
1 Print (Bin (2), type (Bin (2))) 2 Print (Bin) 3 Print (Bin (20))
?
bool ([x]):Used to convert a given parameter to a Boolean type, or False if there are no arguments
[Note]:bool is a subclass of int
1 Print (bool ()) 2 Print (BOOL (1)) 3 Print (BOOL ([1,2,3,4])) 4 Print (Issubclass (Bool,int)) # determine if BOOL is a subclass of int
Continue ...
Python: Summary of Built-in functions