Python3 function parameters, python3 function parameters
1 ## General parameter 2 # def jiafa (a, B): 3 # print (a + B) 4 #5 # jiafa (5, 6) 6 #7 #8 # def xinxi (name, location, sex = 'male'): # The default parameter is 9 # print ('name: % s' % name) 10 # print ('gender: % s' % sex) 11 # print ('hometown: % s' % location) 12 #13 #14 # xinxi ('bob', 'shansi') 15 #16 # variable length parameter 17 # def add (* jiafa): # * followed by a tuple, random name, generally write args (no name parameter) 18 # print (jiafa) 19 # sum = 020 # for I in jiafa: 21 # sum + = i22 # print (sum) 23 # add (, 5) 24 #25 # def informations (** info): # ** use a dictionary later. The name is random. Generally, write kwargs (with naming parameters) 26 #27 # for I in info: # I is the key, info is the value 28 # print ('% s: % s' % (I, info [I]) 29 # informations (name = 'lily', age = 18, sex = 'female ', job = 'deletewoman', location = 'beijinging ') 30 #31 # def test (* a, ** B): 32 # print (a, B) 33 # test ('asd ', 2, 22, ['asd ', 1], (, 5), name = 'bob') 34 35''' 36 about the location of the indefinite length parameter * put agrs on the left, ** put kwargs on the right 37. The default value is 38 to the left of the variable length parameter. The order is keyword parameter, default value parameter, * args, ** kwargs39 '''