如果想搞清楚python的*args **kargs什么意思,看下如下代码便清楚了.
其实*args指的就是不带key的可变参数, **kargs就是带key的可变参数.
def foo_single_arg(arg): print("arg = ", arg) def foo_multi_args(arg, *args): print("arg = ", arg) print("*args = ", args) def foo_multi_args_with_key(arg, *args, **kargs): print("arg = ", arg) print("*args = ", args) print("**kargs = ", kargs)
输出结果:
文章的脚注信息由WordPress的wp-posturl插件自动生成