Built-in function description:
Built-in parameters official detailed Https://docs.python.org/3/library/functions.html?highlight=built#ascii
Here is my understanding of commonly used built-in functions:
Print(ABS (-1))#Absolute value 1Print(All ([1, 2, 3, 4, 5]))#TruePrint(All (["', 1, 2]))#False#case where bool is false 0, NULL, NonePrint(Bin (12345), type (Bin (12345)))#0b11000000111001 <class ' str ' >Print(Chr (97))#convert numbers to character a according to the ASCLL tablePrint(Ord ("a"))#convert characters to digital by ASCLL tablePrint(Divmod (10, 3))#return (quotient, remainder) (3, 1)Print(ID (1))#View memory addressPrint(Isinstance ("123", int))#FalsePrint(Type ("123") isStr#Judging data type TruePrint(Len ("123"))#3Print("123".__len__())#Calculated length 3Print(Pow (2, 3))#2 of 3 square 8Print(Pow (2, 3, 3))#The first two parameters are the secondary side, and the latter parameter is the remainder operation 2Print(Type (repr (1234)))#turn 1234 into string <class ' str ' >Print(Type (str (1234)))#<class ' str ' >L= [1, 2, 3] forIinchReversed (L):#print backwards. Print(i)Print(Round (3.5))#Rounding 4Print(Round (3.3))#3Print(L[0:3:2])#slicing [1, 3]A = Slice (0, 3, 2)Print(L[a])#slicing [1, 3]Print(Sum ([1, 2, 3, 4, 5]))#sum OperationPrint(Sum ([1, 2, 3, 4, 5]), 100)#you can set the initial value to 100, and the result isPrint(sum ([], 100))# -Print(Eval ("1+2*3/4"))#parses and executes an expression in the form of a string: 2.5a="print (' Hello exec ')"exec(a)#parse and execute code in string form: Hello exec#compile () #几乎用不到 #把一个代码文件加载进来, parse and execute by exec and evaldefSayhi (): Name="YL" Print(Locals ())#Print local variable {' name ': ' YL '} Print(Globals ())#Print Global VariablesSayhi ()#-------------------------------------------------------------------------------------#map (function, Sequence1, sequence2 ...)A = Map (LambdaX:x*x, Range (10))Print(a)#<map object at 0x000001cbf8573a20>Print(List (a))#[0, 1, 4, 9, +,-#multiple sequence can be processed to implement a function method for Sequence1,sequence1,.. Process, which requires that the function also supports the corresponding number of parameter inputs:A = Map (LambdaX, Y, z:x+y+z, Range (ten), Range (10))Print(List (a))#[0, 3, 6, 9, A, (+) ,-#------------------------------------------------------------------------------------------#-------------------------------------------------------------------------------------#reduce (function, sequence, starting_value):#only one sequence,starting_value is processed to initialize the value, the order of execution is: first the first value inside each sequence and the Starting_value function,#The result of the processing is then treated with the second value of the sequence function until the end. #->reduce function must enter two variables to perform the Operation fromFunctoolsImportReducePrint(Reduce (LambdaX, Y:x + y, [2, 3, 4, 5, 6], 1))# +#The result is a 21 execution sequence of----> (((((((1+2) +3) +4) +5) +6))Print(Reduce (LambdaX, Y:x + y, [2, 3, 4, 5, 6])# -#-------------------------------------------------------------------------------------#------------------------------------------------------------------------------------#filter (function, sequence): Performs function (item) in sequence on item in sequence, with only 1 sequenceA = Range (10) b= Filter (LambdaX:x > 5, a)Print(b)#<filter object at 0x00000204addc0748>Print(list (b))#[6, 7, 8, 9]Print(List (Filter (LambdaX:x+5, a)))#[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]#Filter can be thought of as a filtering function, it does not seem to modify the value inside the sequenceL= [1, 2, 0, 4, 0, 7]Print(List (filter (None, L)))#when function is None, the return is Ture's item:[1, 2, 4, 7]#-------------------------------------------------------------------------------------a= List (Range (10))Print(a)#[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]b = List (range (10, 16))Print(b)#[Ten , one, a, a, a.]Print(List (Zip (A, b)))#[(0, Ten), (1, one), (2, a), (3, +), (4, +), (5)]#Printmsg ="and back to the beginning."F= Open ("ToFile","W")Print(MSG,"the memory of your green face", sep="|", end="", file=f)#write in file ToFile: Back to the original starting point | Remembering your green faceImportTime#it's old. forIinchRange (10): Time.sleep (0.5) #print (".") Print(".", end="", flush=True)#Import SYS#print ("---", VARs (SYS))#print ("...", dir (SYS))#Import Time#For N in (100000, 200000, 300000, 400000):#data = B ' x ' *n#start = Time.time ()#B = Data#While B:#B = b[1:]#print (' bytes ', N, Time.time ()-start)##For N in (100000, 200000, 300000, 400000):#data = B ' x ' *n#start = Time.time ()#B = Memoryview (data)#While B:#B = b[1:]#print (' Memoryview ', N, Time.time ()-start)
Summary: Differences between the map, filter, and reduce three functions
The map function can have multiple sequence parameters and can modify the value of item in the parameter sequence
The filter function can have only one sequence parameter and cannot modify the value of item in the parameter sequence, which is equivalent to a filter function
The reduce function can have only one sequence parameter, and cannot modify the value of item in the parameter sequence, Equivalent to an additive function whose function parameter must have two arguments passed in
Python Path--python Foundation 4--built-in functions