Considerations for named keyword arguments and keyword argument calls

Problems that arise

Insert image description here
Insert image description here

Notes on using keyword parameters

Insert image description here
So the key is to see clearly what the signature of the function is.

  • Different signatures of functions have different ways of writing parameters when calling.
  • When calling named keyword parameters, the name of the keyword must be written clearly.
  • If the keyword parameter has a default value, you do not need to write it
  • Named keyword arguments can be assigned values ​​out of the order of declaration.

think

When calling the defined function here, data cannot be passed in directly. The parameters passed in at this time are required parameters, which are positional parameters.

  • However, in the program, the named keyword parameters need to be passed in, so the data must be declared as named keyword parameters and then passed in.

Correct way to write:**data

Learn to test code

Supongo que te gusta

Origin blog.csdn.net/weixin_44943389/article/details/133012504
Recomendado
Clasificación