python 函数中参数 * **

* 接受参数类型为元组

In [16]: def  func(a,*pargs):
    ...:     print(a,pargs)
    ...:

In [17]: func(1,2)
1 (2,)

In [18]: func(1,2,3,4)
1 (2, 3, 4)

** 接受参数类型为字典

In [25]: def func1(a,**kargs):
    ...:     print(a,kargs)
    ...:

In [26]: func1(1,b=2,c=3)
1 {'b': 2, 'c': 3}

In [27]: func1(1,b=2,c=3,d=4,e=5)
1 {'b': 2, 'c': 3, 'd': 4, 'e': 5}

猜你喜欢

转载自www.cnblogs.com/min-sir/p/12073272.html