built-in function

Anonymous function: lambda n: print(n) 
all objects are non-zero or True, and empty is False #If
all
objects in all() are true, return True, otherwise False a = all([ " aaa " ,12 ,0 ]) print (a)
#If any of the objects in any() is true, return True, otherwise 
a = any([ " aaa " ,12 ,0])
 print (a)
#Decimal to binary 
a=bin(255 )
 print (a)
#Print out the Ask code of a certain word 
a=bytearray( " abcdef " ,encoding= " utf-8 " )
 print (a)
#Absolute value 
a=abs(-100016 )
 print (a)
# #Accumulated instances of built-in functions 
import functools
res = functools.reduce(lambda x,y:x+y,range(100))
print(res)
# # Turn a set into an immutable set 
a = frozenset([12,3,5,8,5,6,5,4])
# ##Precise floating point number 
round(1.3334,2 )
 # #2, this is how many decimal places to keep
# # Sort a dictionary into a list 
a= {6:2,8 :0}
 print (sorted(a.items))

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324831909&siteId=291194637