In this example, we will discuss the parameter passing problem of the function.
The python version I use is 3.3.2.
For functions:
fun( == main()
Information.
The printed information here is:
hello,Hongten
For the following use cases:
fun(a=1, b=None, c=None, * ( fun(a= fun( == main()
When the passing parameters are fun (a = 'one') and fun ('one'), the values are copied to parameter, the effects of all two parameters are the same:
Of course, we can also assign values to parameters B, c, and * args.
For example:
fun(a=1, b=None, c=None, * ( fun(,1,2,( == main()
In this way, values are assigned to parameters B, c, and args.
Running effect:
one,1,2,(,)
In the preceding column, we cannot bypass the parameters a, B, and c in front of * args to copy * args:
For example:
fun(a=1, b=None, c=None, * ( fun(args=( == main()
Running effect:
, line 21, <module>, line 18, =(
However, for parameters a, B, and c, you can assign values in this way.
For example:
fun(a=1, b=None, c=None, * ( fun(c=(), b=2, a=[1,2,3 == main()
Running effect:
[1, 2, 3],2,hongten,()