#!/usr/bin/env python#-*-coding:utf-8-*-#Author:huanglinsheng" "Python built-in function https://www.runoob.com/python/python-built-in-functions.html" "#any (x) determines whether the X object is an empty object, returns False if all is empty, 0, false, or true if not all is null, 0, False#All (x) returns True if All (x) parameter x is not 0, ', false, or x is an empty object, otherwise falsePrint(All (["', -5,3]))Print(Any (["', -5,3]))########### Mathematics-related ##############ABS (a): the absolute value is obtained. ABS ( -1)#max (list): The list maximum value is obtained. Max ([+])#min (list): The list minimum value is obtained. MIN ([+])#sum (list): Takes the sum of the list element. SUM ([i]) >>> 6#sorted (list): Sort, returns the sorted list. #len (list): List length, Len ([+])#Divmod (A, B): Gets the quotient and remainder. Divmod (5,2) >>> (2,1)#Pow (A, B): Gets the number of squares. Pow (2,3) >>> 8#round (A, B): Gets the decimal number of the specified digits. A represents a floating-point number, and B represents the digits to be retained. Round (3.1415926,2) >>> 3.14#Range (A[,b]): Generates an array of a to B, left closed right. Range (1,10) >>> [1,2,3,4,5,6,7,8,9]############ #类型转换 ##############int (str): converts to type int. Int (' 1 ') >>> 1#Float (INT/STR): Converts an int or character type to a floating-point type. Float (' 1 ') >>> 1.0#str (int): Converts to a character type. STR (1) >>> ' 1 '#bool (int): Converts to a Boolean type. STR (0) >>> false str (None) >>> false#bytes (str,code): Receives a string, with the format to encode, returns a byte stream type. Bytes (' abc ', ' Utf-8 ') >>> b ' abc ' bytes (U ' crawler ', ' Utf-8 ') >>> B ' \xe7\x88\xac\xe8\x99\xab 'A = bytes ("ABCDE", encoding="Utf-8")Print(A.capitalize (), a)#to ASCII, then modify the ASCII code for the listb = ByteArray ("ABCDE", encoding="Utf-8")Print(b[0]) b[1] = 50Print(b)#list (iterable): Convert to list. List (>>>)#iter (iterable): Returns an object that can be iterated. ITER ([<list_iterator]) >>> object at 0x0000000003813b00>#dict (iterable): converted to Dict. Dict (' A ', 1), (' B ', 2), (' C ', 3)]) >>> {' A ': 1, ' B ': 2, ' C ': 3}#Enumerate (iterable): Returns an enumeration object. #tuple (iterable): converted to tuple. Tuple ([+]) >>> ( all in all)#Set (iterable): converts to set. Set ([1,4,2,4,3,5]) >>> {1,2,3,4,5} set ({1: ' A ', 2: ' B ', 3: ' C '}) >>> { -i}#Hex (int): converted to 16 binary. Hex (1024x768) >>> ' 0x400 '#Oct (int): converted to 8 binary. Oct (1024x768) >>> ' 0o2000 '#bin (int): converted to 2 binary. Bin (1024x768) >>> ' 0b10000000000 'Print(Bin (10))#chr (int): Converts the number to the corresponding ASCI code character. Chr >>> ' A 'Print(Chr (98))Print(Chr ('b'))#Ord (str): Converts the asci character to the corresponding number. Ord (' A ') >>>############## related Operations ##############eval (): Executes an expression, or string as an operation. Eval (' + + ') >>> 2#exec (): Executes the Python statement. EXEC (' print ' ("python") ') >>> Python#Filter (func, iterable): Filters the elements that match the criteria by judging the function fun. Filter (lambda x:x>3, [1,2,3,4,5,6]) >>> <filter object at 0x0000000003813828>#Map (func, *iterable): Uses Func for each Iterable object. Map (Lambda a,b:a+b, [1,2,3,4], [5,6,7]) >>> [6,8,10]#Zip (*iterable): Merges the iterable groupings. Returns a Zip object. List (Zip ([1,2,3],[4,5,6])) >>> [(1, 4), (2, 5), (3, 6)]#Type (): Returns the type of an object. #ID (): Returns the unique identity value of an object. #Hash (object): Returns the hash value of an object with the same value as an object with the same hash value. Hash (' python ') >>> 7070808359261009780#Help (): Call the system's built-in assistance system. #isinstance (): Determines whether an object is an instance of the class. #Issubclass (): Determines whether a class is a subclass of another class. #Globals (): Returns the dictionary of the current global variable. #Next (iterator[, default]): Receives an iterator that returns the numeric value in the iterator and, if default is set, outputs the default content when the elements in the iterator are traversed. #Reversed (Sequence): Generates an iterator that reverses the sequence. Reversed (' abc ') >>> [' C ', ' B ', ' a ']
python--common built-in functions