Python parameters in function: A required transmission parameters (position parameter), the default value of the parameter, the parameter set transmission parameters, parameter passing keywords

 1, will also pass parameters known position parameters, as required, must correspond to the position

 

2, the default value of the parameter as shown above word

 

3, parameter set parameters: pass in is 0, or in the form of a plurality of parameters and a position value of a bit like ,,, only pass value value, but without limiting the number of

 

4, parameter passing Keywords: pass in is 0, or a plurality of key = value form, the key parameter passing, do not write back the position parameters

 

Will pass the parameter, the default value of the parameter, the parameter set transfer parameters, application key parameter passing

 


def func(a,b,c):
print(a,b,c)

list1=[1,2,3]
list2=(3,2,3)
list3='4','2','3'
dict={'a':'2','b':'2','c':'3'}
func(*list3)
FUNC (** dict) 

DEF cs (name, Age = None, * addr, like **):
Print (name, Age, addr, like)
cs ( 'Joe Smith', 18, 'Shanghai', 'Beijing' motion = 'football', eat = 'cake')

Guess you like

Origin www.cnblogs.com/mihoutao/p/10818762.html