Custom function calls and default values

Function is called using 'parameter = value' approach
fun (age = 10, name = 'Tom') // without regard to the order
Left support is not specified, the specified parameter list on the right, and vice versa is not supported as fun (name = 'Tom', 20)
 
When the function is defined, the default value of the parameter with no left discharge, discharge parameters with default values ​​to the right
def fun(name,age=20):
    print('name%s,age%s'%(name,str(age)))
 
A plurality of shape function parameters, arguments with * or ** last label, positioning the last, variable represents or dictionary tuple
def fun(name,*info):
    ....
 
fun('Jack',18,180,'M')
 
Function parameters can be lists, tuples, dictionaries. Note that the function call is directly transmitted variable name (the actual delivery address), the value will be changed in synchronization. To copy here
 

Guess you like

Origin www.cnblogs.com/guoyujiang/p/11594586.html