One, variable 1, reference ID ()
A function that participates in a return value is a reference to the saved data.
2, mutable and immutable types (the reference address of a variable changes only after the assignment statement)
- Immutable type data in memory is not allowed to be modified
- Number Type Int,bool,float,complex,long (2,x)
- String str
- Tuple tuples
- Data in variable-type memory can be modified
- Lists List
- Dictionary Dict
- The dictionary key can only use immutable type data
- Hashing (hash)
- A function called hash (0) is built into Python.
- Accept an immutable data as a parameter returns a result as an integer
- A hash is an algorithm that extracts the signature (fingerprint) of the data.
- Same content gets the same result
- Different content gets different results
- When setting a dictionary key-value pair in Python, the key is first hashed to determine how to save the dictionary data in memory to facilitate subsequent additions and deletions.
- Key-value pairs must be of immutable type data
- Value can be any type of data
3. Local variables and global variables
Second, function 1, tuples can return multiple values
2. Exchange two variables
# The right side of the equals sign is a tuple, just omitting the parentheses , a, B, a
3. Using methods inside a function to modify variable parameters affects external arguments4. The list variable encounters the Extend method which is essentially a list variable
5. Default parameter (a default value specified for a parameter)
- Example: (typically using the most common values as default values for default parameters)
- Default parameters with defaults are placed at the end of the parameter list!!!
- To specify the parameter name when multiple default parameters have defaults
6. Multivalued parameters (the number of arguments to be processed by the function is indeterminate)
- Add a * to receive tuples before the parameter name
- Add a * * before the parameter name to receive the dictionary
The general habit of the following two names:
- *args the meaning of the abbreviated variable that holds the tuple parameter arguements
- **kwargs the meaning of the abbreviation key value of the keyword for storing the tuple parameter to the parameter
Split Package
Example:
Basic knowledge of Python (v)