Python operation principle: Import #导入, is to let a file using another file code Python code running principle 1,open open file, read read file 2, after the code is written, check the syntax is incorrect 3, the syntax is compiled to PYC byte code 4, Run-time bytecode conversion to machine code for CPU call execution, all the execution is a py file, including classes, functions, lists, are a py file Python encoding: The default is Ascil encoding, 8 bits, one byte in three, the default is Utf-8, Utf-8 is optimized for Unicode, Unicode is at least 16 bits 2 bytes in 2 need to be specified, default is Unicode, need to specify the encoding conversion, Unicode conversion to UTF-8 is encoded, Utf-8 converted to Unicode for decoding different encoded conversions, preferred to convert decoded to Unicode in a column encoded from Unicode to other columns such as Utf-8---UNICODE--GBK because other encodings are optimized for Unicode development Python executes script passed in parameter: sys this. py file module contains all of Python's functions associated with the import sys #导入它, and then you can use the features it contains, print (SYS.ARGV) #argv, to receive all of the interpreter's parameter, type is a list, after use, in the editor to enter a random number, will be added to it inside PYc file, byte code: If there is a pyc file, delete the py file, the program can also execute, because it is the PY compiled bytecode, priority will find it, if it is changed, it will be new to the PY compiler Address pool cache: Reduce memory burden, enhance efficiency fractional sub-pool, 5 to 257 dedicated to the storage of decimal, in memory, if you do not have it, you use a 5, will be in memory to open up 5 memory address, waste space, There's a small number called 5. It calls the string pool from this pool: Use the algorithm to save high-weight strings in this pool, easy to call, reduce the opening of the address space
lists, tuples also have, tuples, collections of elements, a series of elements
exit #退出程序, exit (0), return number, similar to Shell
tuples are the same as list functions, but elements cannot be modified
list definition a=[1,2,3] tuple definition a=
elements of tuples cannot be modified
element of a tuple element can be modified
columns such as
t1= (1,2,3,{' K1 ': ' V2 ': ' C3 '}) #{' K1 ': ' v2 '} This is the dictionary K1 is the key value, the V2 is the corresponding element of the key value, each corresponding, a pair of
t1[1]=2 #元素2不可以修改
t1[3][' K1 ']=2
#字典里的k1元素可以修改, the whole dictionary as an element can not be modified
print (t1)
aa={' K1 ': ' v1 ', ' K2 ': ' v2 '} #定义字典
Dictionary:
index: Is indexed by key value
Basic knowledge of Python review