函数调用--不定长参数

Posted moxiao

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了函数调用--不定长参数相关的知识,希望对你有一定的参考价值。

 

def func(arg,*args_tuple,**args_dic)

带*的参数会以元组的形式导入,带**的参数会以字典的形式导入

def fuc(a,*arg):
    print(a)
    print(arg)

fuc("hello",1,2,3,4,5)

输出结果:

技术图片

 

def fuc(a,*arg,**dic):
    print(a)
    print(arg)
    print(dic)

fuc("hello",1,2,3,4,5,d=3,b=4,c=5)

 

输出结果:

 

技术图片

以上是关于函数调用--不定长参数的主要内容,如果未能解决你的问题,请参考以下文章