首页 > 代码库 > 不定参数

不定参数

#!/usr/bin/env python
# -*- coding:utf-8 -*-


def fun1( *args, **kwargs ):
    print( args, type(args) )
    print( kwargs, type(args) )

fun1(12, aa, 234, kk=1, nn=4)
aa=[1, 2, 3, 4]
b = {a: 1, b: 2, c: 3}
fun1(*aa, **b)

C:\Users\DELL\AppData\Local\Programs\Python\Python35\python.exe I:/untitled1/b.py
(12, ‘aa‘, 234) <class ‘tuple‘>
{‘nn‘: 4, ‘kk‘: 1} <class ‘tuple‘>
(1, 2, 3, 4) <class ‘tuple‘>
{‘b‘: 2, ‘c‘: 3, ‘a‘: 1} <class ‘tuple‘>

不定参数