*args用于接受传入的值,无限制,但是不能接收key类型的,如c=2
def fun(*args): for i in args: print(i) print("test") fun("aa","bb","cc") 结果: aa bb cc test
fun("aa","bb","cc",d=2)如果传入d=2将会报错
**kwargs可以接收key类型的,上面的报错,使用**kwargs就可以了:
def fun(*args,**kwargs): for i in args: print(i) print("test") fun("aa","bb","cc",d=2)