1. the variable name with an asterisk (*) will hold all the unnamed variable parameters, cannot store dict, or error.
Such as:
1 defMultiple (ARG, *args):2 Print "ARG:", Arg3 #print variable length parameters4 forValueinchargs:5 Print "Other args:", Value6 7 if __name__=='__main__':8Multiple (1,'a', True)
Output:
2. the variable name with an asterisk (* *) holds all the unnamed variable arguments
1 defMultiple2 (* *args):2 #print variable length parameters3 forKeyinchargs:4 PrintKey +":"+bytes (Args[key])5 6 if __name__=='__main__':7Multiple2 (name='Amy', age=12, Single=true)
Output
3. There are *args and **dictargs:
1 defMultiple (ARG, *args, * *Dictargs):2 Print "ARG:", Arg3 #Print args4 forValueinchargs:5 Print "Other args:", Value6 #prints the indefinite length parameter of the dict type args7 forKeyinchDictargs:8 Print "Dictargs:"+ key +":"+bytes (Dictargs[key])9 Ten if __name__=='__main__': OneMultiple (1,'a', True, Name='Amy', age=12,)
Output:
Python variable length parameter *args, **dictargs