'
def Test (*args): # *AGRS receives n positional arguments, cannot accept keyword arguments, conversions Cheng Yuanju
Print (args)
Test (1,2,3,4,5,6)
Test (*[ 1,2,4,5,5] # arge=tuple ([1,2,3,4,5])
def test1 (X,*args):
Print (x)
Print (args)
def test2 (**kwa RGS): #接受n个关键字参数, convert n keyword arguments to dictionary
Print (Kwargs)
Print (kwargs["name"])
Print (kwargs[' age ')
Print ( kwargs["Sex"])
Test2 (name= "Alex", age=8,sex= ' F ')
#test2 (**{' name ': ' Alex ', "Age": 8})
def test3 ( Name,**kwargs):
Print (name)
Print (Kwargs)
Test3 (' Alex ', age=18,sex= "M") #必须是关键参数, not directly a string test3 (' Alex ', ' sddd ', sex= "M")
def test4 (Name,age=18,**kwargs): #默认参数写到后面? No, the parameter group is going to the rear
print (name)
Print (age)
Print (Kwargs)
Test4 ("Alex", sex= ' m ', hobby= ' Tesla ', age=3) #默认 Age can be put in the back? Yes, can be positional parameter, can keyword parameter
' '
' '
def test5 (Name,age=18,*args,**kwargs):
Print (name)
Print (age)
Prin T (args)
Print (Kwargs)
Test5 ("Alex", sex= ' m ', hobby= ' Tesla ')
'
*args, **kwargs parameter groups