Python自定义函数的参数

在Python中自定义的函数可以有三类不同的参数

  • formal parameters
  • positional arguments
  • Keyword Arguments

 

When a final formal parameter of the form **name is present, it receives a dictionary (see Mapping Types — dict) containing all keyword arguments except for those corresponding to a formal parameter. This may be combined with a formal parameter of the form *name (described in the next subsection) which receives a tuple containing the positional arguments beyond the formal parameter list. (*name must occur before **name.) For example, if we define a function like this:

posted on 2018-06-05 17:55  yanzibuaa  阅读(770)  评论(0编辑  收藏  举报