1. Position parameter:>>> def Check_web_server (host, port, path): Print ... >>> check_web_server (' www.python.org ', 80, '/') three parameters Shun The order must be one by one, and less than one parameter
2, (in the function call) keyword parameters:It can make the function clearer and easier to use, and also clears the order requirements of the parameters, which are specified by "key-value" for function calls >>> Check_web_server (port=80, host= ' Www.python.org ', path= '/') (three parameters of the location can be arbitrary)
3, (in the function signature) default parameters:Providing default values for parameters, which are not required to pass parameters to them, is used for function definitions (note: All positional parameters must be present before optional parameters, including function definitions and invocations) >>>defCheck_web_server (host, port=80, path= '/'):#
the right
Print ...>>>defCheck_web_server (path= '/', Host, port=80): #
wrong (the location parameter host must be first on the front)
Print ...>>> check_web_server (' www.python.org ') #
OK (port and path are default values)>>> check_web_server (' www.python.org ', port=8080)
#
OK (path is the default value)>>> check_web_server (port=8080, ' www.python.org ') #
No (position parameter must be at the front)
I love python. Position parameter, keyword parameter, default parameter