一、可变参数
1.元组
"""可变参数"""
def test01(a,b,*c):
print(a,b,c)
test01(10,20,33,44,55) # 10 20 (33, 44, 55)
2.字典
def test02(a,b,**c):
print(a,b,c)
test02(1,2,name="chu",age=18,job="teacher") # 1 2 {'name': 'chu', 'age': 18, 'job': 'teacher'}
3.万能参数
def test03(a,b,*c,**d):
print(a,b,c,d)
test03(111,222,33,44,55,name="baobao",age=18) # 111 222 (33, 44, 55) {'name': 'baobao', 'age': 18}
二、强制命名参数
"""强制命名参数"""
def test04(*a,b,c):
print(a,b,c)
#test04(666,777,88,99) # test04() missing 2 required keyword-only arguments: 'b' and 'c'
test04(666,777,b=12,c=13) # (666, 777) 12 13