Python path [Article 4]: Python-based functions, Article 4
Function understanding
Process-oriented: code from top to bottom according to business logic
Function: encapsulate a function code into a function. You do not need to write it again later. You only need to call the function.
Function is used to ensure good scalability and reusability of your program.
If the same function is used more than three times, we recommend that you use the function.
Special understanding:
Functions can be understood as one function block. You can split a large function into one block and call a function block when using a function!
Functions can be understood as Lego blocks. You can use these blocks to form any function you want!
Functions can call functions! The main function is to concatenate and call functions! The function itself cannot be executed by itself. If it is not called, it will never be executed!
# ----------------------------------------------- Def func1 (): passdef func2 (): passdef func3 (): passdef func4 (): pass func1 () func2 () func3 () func4 () if _ name _ = '_ main _': # Call the above function. The function is judged and called cyclically! # You can also call the function example in the function: def func4 () :#__ name _. This is used to judge, if you import this program as a module, its _ name _ is equal to the program file name. If you manually execute this script, for example, python test. in py, _ name _ is equal to _ main _. Therefore, we can use it for judgment. if you execute it manually, I will call the function to execute the statement below if, if you call the if statement in the module to determine whether the statement is executed! Only used by modules! # If a function is imported into a module, the name of the function is imported, and the content is not imported, the function information will be imported only when you call the function.
Directory 2
Test .............. 2
Subdirectory 3
Test ......
Directory 4
Test ......
Directory 5
Test ......