1. Brief description Python 's Running process
before we say this question, let's start with two concepts, Pycodeobject and pyc files.
The PYc we see on the hard drive naturally doesn't have to say much, and pycodeobject is actually the result of a Python compiler actually compiling it. Let's just get to the bottom of it and keep looking down.
when the Python program runs, the result of the compilation is stored in the pycodeobject in memory , and when the python program finishes running, The Python Interpreter writes the pycodeobject back to the pyc file.
when the Python program runs for the second time, the program will first look for the pyc file on the hard disk, and if it is found, load it directly or repeat the process.
so we should be positioning ourselves like this. Pycodeobject and pyc files, we say that the pyc file is actually A persistent way of saving pycodeobject.
2.copy is a shallow assignment and only assigns the memory address of the first layer.
3. Output How the index in the For Loop is handled.
4. Functional Programming ---- procedural programming using def definitions
Procedure is a function with no return value
5. Why does the function need to have a return value?
the maximum effect is to get the only result after the function operation
6. How functions are called
defTest (x, y):Print(x)Print(y)#positional parameter invocation: The form participation argument must be one by one corresponding#Test (1,3)#keyword Call: Location does not need to correspondTest (y=1,x=2)#mix: Keyword calls must be after positional parametersTest (1,y=3)defTest (x,y=2): Print(x)Print(y)" "functions with default parameters, when calling a function, the default parameter must not be passed" "#Pass only one entry, using default parametersTest (1)#Pass two parameters: The argument overrides the default valueTest (+)
(1) Formal parameters
*args: Accepts n positional parameters, the conversion Narimoto group accepts an invariant parameter (positional parameter)--- becomes a tuple
def Test (*args): print(args) test (3,5,7,8)#(3, 5, 7, 8) Output Results
(2) **kwargs: The way to convert N keyword parameters into a dictionary.
def Test (* *Kwargs) :print(kwargs) test (name='wfb') , age=19)# {' name ': ' WFB ', ' age ': +} Output Results
Python trivia points (2)