The method of parameters given in Python

def fun(self, a, b, c=None): The default value can be given, but must be given all in the rightest def fun(self,a,b, *c): The group of parameters can be given, but only one of the default parameters and group parameters can be given. It conform to the logical. The group parameters is stored in a tuple. When giving the parameters, if a is a list. fun(*a) is giving the element of a list to the function, fun(a) is giving a list to the function... if b is a dictionary, fun(b) is giving a dictionary to the function, fun(*b) is giving the key of the dictionary to the function, fun(**b) is given the item of the dictionary to the function.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章