Common:
# ABS (), all (), any (), bin (), BOOL (), Chr (), Dict (), dir (), Divmod (), Enumerate (), eval (), filter (), float (), # Help (), Hex (), ID (), input (), int (), Len (), list (), map (), Max (), Min (), Oct (), open (), Ord (), print (), # range (), reversed (), round (), set (), sorted (), str (), sum (), tuple (), type (), VARs (), zip ()
Https://docs.python.org/3.5/library/functions.html
1.abs () absolute value
1 Print (ABS ( -34)) # Absolute Value 2 # Output Result:
2.all () All true, true or false
1 Print (All ([1,2,4,bool (")])) # if not all is true, then false 2 # output Result: False
3.any () There is a true, then true, otherwise all false is False
1 Print (Any ([1,2,3,bool (")])) # It's all fake, or it's true. 2 # output Result: True
4.ascii () call __repr__ () This method, returning a string, as with repr ()
1 #define a class2 classFoo:3 def __repr__(self):4 return "bbbbb"5f =Foo ()6RET =ASCII (f)7 Print(ret)8 9 #output Result: bbbbb
5.bin () Convert numbers to binary
1 Print (BIN) # Convert to binary 2 # execution Result: 0b1010
6.bool value, judging true and false
1 Print (bool (0)) # The default 0 is False, the other number is true, 2 output Result: False 3 # In addition none, empty string, empty tuple, empty list, empty dictionary, etc. are all false
7.bytearray () converted to byte array format
1 p = ByteArray (" sogou ", encoding="utf-8") # Convert to byte array 2print(p) # A Chinese representation of 3 bytes 3# Output Result: ByteArray (b ' \xe6\x90\x9c\xe7\x8b\x97 ')
8.bytes () convert to string format
1 p2 = bytes ("aaa sogou AAA", encoding="utf-8") # Convert to String 2print(p2)3# output: B ' aaa\xe6\x90 \x9c\xe7\x8b\x97aaa '
9.callable () Determine if executable
1f =LambdaX:x+12 Print(F (5))3 Print(Callable (f))#callable can check to see if f () can perform4Li = []5 Print(Callable (LI))#The result is false, which indicates that Li () is not executable6 7 #Execution Result:869 TrueTenFalse
10.CHR () Converts a number in the ASCII code to a character, and Ord converts the characters in the ASCII code to a number.
1 Print (CHR) 2 Print (Ord ("H")3# output Result:4C 5 104
11.enumerate () plus number
1 for in Enumerate (li,3): # Initial value 3 can define 2 print(i,item) 3# output:4 3 SDD5 4 DFF6 5 dddd
12.eval () capable of executing algorithms in strings
1 " 6*8 " 2 Print (eval (s)) # an algorithm for the character of Eval-capable arithmetic words 3 # Output Result:
13.filter () filtering (less than before and after data), map () filtering (the number of data before and after the change)
1S1 = [11,22,33,44]2NEW_S1 = Map (LambdaX:X+100,S1)#filter, each element will be looped3 Print(List (NEW_S1))4 5 deffunc (x):6 ifX>33:7 returnTrue8 Else:9 returnFalseTenn = Filter (FUNC,S1)#value for filter true One Print(list (n)) A - #Execution Result: -[111, 122, 133, 144] the[44]
14.frozenset () freezes the collection, i.e. cannot add modifications, etc.
15, hash () to convert the string into a hash value to store, this way can save space
16, Max () gets the maximum value in a set of data, Min () gets the maximum value in a set of data
17.OCT () converted to octal
1 Print (Oct (+)) # octal 2 # output Result: 0o144
18, round () rounding
1 Print (Round (8.4)) 2 # Output results: 8
19.sorted () sort
20.sum () summation
21.dir () returns the Key,var () returned by all
22.zip () one by one correspondence
x = [A]y= ["h","I","J"]zipped= Zip (x, y)#one by one correspondencePrint(List (zipped))#Execution Result:[(1,'h'), (2,'I'), (3,'J')]
Python built-in functions