python学习笔记 - 函数: 传参字典/键值对

#传参: 字典/键值对
def func(**kvargs):
    print('解包字典:')
    for k, v in kvargs.items():
        print('{}:{}'.format(k, v))

#传键值对
func( name= 'Tom',  age = 20)

#传字典
employee = dict(name = 'Tom', age = 20)
func(**employee)

打印结果:
解包字典:
name:Tom
age:20

解包字典:
name:Tom
age:20

 

posted @ 2017-04-19 23:00  C/C++/Python/Java  阅读(7107)  评论(0编辑  收藏  举报