1.r=compile (S, "<string>", "exec")
Compile () compiles a string into Python code
2.exec (r) Execute Python code
3.eval ("8*6") eval ("") can only execute an expression, the execution of Eval () will have a return value, exec executes no return value.
4.filter and map
Filter (the function, which iterates over the object), returns a collection of elements that meet the criteria. Filter on an iterative object.
Map (a function, an iterative object) is equivalent to a for loop, processing each element and returning new processing results.
5.with open (' config ', ' R ') as F:
For lines in F: This is a one-line load operation that is more efficient than f.readlines () loading all the files into memory
6. Data with a value of false
0, None, "", [], {}, ()
7.all () and any ()
The two functions receive an object that can be iterated, and all () requires that all data in the object be true before returning true,any () requirements
Returns true if at least one data in the object returns True
8.bin () receive 10 binary converted into binary
Oct () decimal "octal"
Hex () decimal "hex"
9.utf-8 encoding A Chinese character is 3 bytes, GBK encoding a Chinese character is 2 bytes. One byte is 8 bits
n = bytes ("Kanji", encoding= "Utf-8")
Convert Kanji to byte type, n results differ from encoding settings
str1 = str (n,encoding= "Utf-8")
10.CHR () Convert the numbers in the ASCII code table to the corresponding characters
Ord () converts a character to a corresponding number
11.file.open () Gets the contents of the string type.
12.python p1.py Execution Process
1.file.open reads the contents of a file into a string loaded into memory
The 2.python compiler compiles strings into special code
3. Execute code
13.s= "Print (123)"
R = Compile (s, "<string>", "exec") python compile string into Python code
EXEC (R) Exec () can also receive execution string, no return value Python executes the compiled code string
S= "8*7"
Ret=eval (s) Python arithmetic expression and returns the result assigned to RET
Python built-in functions 1