The main record is to learn the course of Python and use it for review and reference.
Knowledge Points:
- Data types (lists, tuples, dictionaries, collections)
- Help documentation
- function (default, variable, keyword, parameter combination)
- List: Lists an ordered set of elements that can be added or deleted, using [] . Variable.
- Tuple: A tuple is similar to a list, but cannot be modified when initialized. Use () to indicate. Immutable.
- Dictionary: Dict uses Key-value storage to find extremely fast, but consumes a lot of memory. Use {} to represent.
- Set: Sets a set of keys, but does not store value. Use ([]) to indicate.
List:
Tuple:
Dict
Set
- Python official web document: https://docs.python.org/2/index.html
- Command line help (function name) such as assist (ABS)
- The function name is a reference to a function object that can be assigned to a variable, which is equivalent to the function having an alias .
2. A function that returns multiple values essentially returns a tuple (tuple).
3. The custom function can check the parameter type and throw an exception.
4. function set default parameters
Note: The required parameter is before the default parameter is
Note: Define default parameters One thing to keep in mind: the default parameter must point to the immutable object.
The list [] is a mutable object, and as a default argument, each call saves the last called value, causing an error.
5. Function setting variable parameters
*nums received a tuple
6. function set keyword parameter (for expanding function function)
In function student, the name and age are required parameters, and the keyword parameter is others. The keyword parameter is automatically combined into a dict(dictionary).
Only required parameters can be passed in:
Pass in any number of keyword parameters:
7. Function set parameter combination
The order in which the parameter combinations are defined must be : Required, default, variable, and keyword parameters.
For any function, it can be called in a similar function(*args, **others)
manner, regardless of how its arguments are defined.