转载自 勤奋的小青蛙
其实*args指的就是不带key的可变参数, **kargs就是带key的可变参数.
示例函数:
1 def foo_single_arg(arg): 2 print("arg = ", arg) 3 4 def foo_multi_args(arg, *args): 5 print("arg = ", arg) 6 print("*args = ", args) 7 8 def foo_multi_args_with_key(arg, *args, **kargs): 9 print("arg = ", arg) 10 print("*args = ", args) 11 print("**kargs = ", kargs)
输出结果: