1,help (i) Help
2,dir (), all variables and built-in variables for the current file
3,vars (), the value of all variables and variables in the current file, and the values of built-in variables and built-in variables
4,type (i), the type of the variable
5,import Temp Import module, the effect of multiple imports is imported only once.
6,reload (temp) can import modules multiple times
7,id (i), shows the memory address of the variable
cmp(2,3)
cmp(2,2)cmp(2,1)cmp(10,1)abs()bool()divmod()max()min()sum()pow(2, 11)------------------len()all()any()------------------chr()ord()hex()oct()bin()------------------printrange(10)printxrange(10)for i inxrange(10): printifork,v inenumerate([1,2,3,4]): printk,v------------------s=‘i am {0}‘prints.format(‘alex‘)str(1)------------------defFunction(arg): printargprintapply(Function,(‘aaaa‘)) #执行函数printmap(lambda x:x+1,[1,2,3]) #allprintfilter(lambdax: x==1,[1,23,4]) #True序列printreduce(lambdax,y:x+y,[1,2,3]) #累加x =[1, 2, 3]y =[4, 5, 6]z =[4, 5, 6]printzip(x, y,z)------------------#__import__()#hasattr()#delattr()#getattr()module =__import__(‘temp‘)printdir(module)val =hasattr(module, ‘version‘)printval------------------#callable() #函数、类必须要有 __call__ 方法#compile#evalcom =compile(‘1+1‘,‘‘,‘eval‘)printeval(com)#exec语句code ="for i in range(0, 10): print i"cmpcode =compile(code, ‘‘, ‘exec‘)execcmpcodecode = "print 1"cmpcode =compile(code, ‘‘, ‘single‘)execcmpcode------------------#isinstance()#issubclass()#super()#staticmethod()
Python built-in functions