Basic knowledge of Python (5) and basic knowledge of python
I. Variable 1. Reference id ()
Both parameter passing and return values of the function are references to the stored data.
2. Variable and immutable types (variable reference addresses only change after the value assignment statement)
- Data in the memory of an unchangeable type cannot be modified.
- Data in a variable type memory can be modified
3. Local and global variables
2. function 1. The tuples can return multiple values.
2. Exchange two variables
# The right side of the equal sign is a tuples, but parentheses a, B = B, a are omitted.
3. Modifying variable parameters within a function will affect external real parameters. 4. List variables encounter the extend method that essentially executes list variables.
5. default parameter (a default value for a parameter)
- Example: (generally, the most common value is used as the default value of the default parameter)
- Default parameters with default values should be placed at the end of the parameter list !!!
- When there are multiple default parameters, you must specify the parameter name
6. multi-value parameters (the number of parameters to be processed by the function is unknown)
- Add a * Before the parameter name to receive tuples
- Add a parameter name ** before the parameter name to receive the dictionary
Generally, the following two names are used:
- * Args stores the meaning of the abbreviated variable of the tuples parameter arguements
- ** Kwargs stores the meanings of key-value pairs abbreviated to keyword of the tuples
Unpacking
Example: