ABS ( -230) #取绝对值all ([0,1,-5]) #如果参数里面的所有值都为真就返回真, otherwise returns false any ([0,1,-5]) #如果参数里面有一个值为真则返回真, otherwise returns false ASCII ([, ' FDS ', ' floating point '] ) #将参数变成字符串bin (8) #十进制转二进制hex (255) #转十六进制oct (4) #转八进制bool (2) #判断参数真假a = bytes ("ABCDE", encoding= "Utf-8") #将字符串转换成二进制b = ByteArray ("ABCDE", encoding= "Utf-8") #将字符串转换成二进制数组b [2] = #然后就可以想数组一样修改值def Test ():p asscallable (test) #判断参数是否能被调用, Test is a function, so it can be called to return TRUECHR #把数字对应的ASCII码字符取出来ord (' d ') #返回对应的ASCII码编号a = {}dir (a) #查看a有什么方法divmod (5,2) #返回参数一处以参数 Two results and remainder a = "a = [1,2,3]b = iter (a) print (b.__next__ ())" "Exec (a) #将字符串编译成代码, and then run res = filter (lambda n:n>5,range (10)) #用来过滤数据, the first is the condition, the second is the data for I in Res:print (i) res = map (lambda n:n*n,range) #用来处理数据, the first one is the processing mode, the second is the data for I in RES:PR int (i) Import functoolsres = Functools.reduce (lambda x,y:x*y,range) #累计处理 #第一个参数是累计的方式, this is additive #第二个参数是需要运算的数据pri NT (res) #45a = Frozenset ([1,4,33,212,54]) #将一个列表变成不可修改的globals () #返回当前文件的所有变量名和值globals (). Get (' a ') #这样可以取出变量名对应的值has H (' Test ') #返回对象的哈希值max () #返return maximum min () #返回最小值pow (3,5) #3的5次方repr (a) #将一个对象转换成字符串round (1.5461,2) #保留2位小数a = {6:2,4:23,34:5,-5:99}sorted (A.items ( )) #按照key值进行排序sorted (A.items (), Key=lambda x:x[1]) #按照value进行排序a = [1,2,3,4,5,6]b = [' A ', ' B ', ' C ', ' d ']for i in Zip (A, b): #将 A and B one by one correspond to make up 4 tuples, the 5,6 in a does not have a corresponding tuple, so print (i) __import__ (' decorator ') is not displayed #将同目录下的decorator. py file Import
Python Learning Path 8-built-in methods