...
1.
In syntax, the return of a tuple can omit parentheses, and multiple variables can receive a tuple at the same time, assigned to the corresponding value by location,
So, the Python function returns a multivalued value that actually returns a tuple, but it's easier to write.
2.
Defining default parameters Keep in mind that the default parameter must point to the immutable object!
3.
Python allows you to precede a list or tuple with an * number, and to change the elements of a list or tuple into mutable parameters.
1 numsp[1, 2, 3] 2 Fun (*nums)
*nums indicates that all elements of the list are nums as mutable parameters. This writing is quite useful and common.
4.
Use of keyword parameters:
1 def Print_person (name, age, * *kw): 2print('name:' ' Age : ' ' Other : ' , kw) 3 Print_person ('Bob', city=,'Beijing') )
5.
One thing to keep in mind when returning closures is that the return function does not refer to any loop variables, or to subsequent variables that change.
6.
By default, the Dict iteration is key. If you want to iterate over value, you can use the for value in D.values () ,
If you want to iterate both key and value at the same time, you can use for K and V in D.items ( ) .
...
My Python Learning Notes (2) (using Python 3)