Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 尝试创建返回并显示列表的函数_Python_Dictionary - Fatal编程技术网

Python 尝试创建返回并显示列表的函数

Python 尝试创建返回并显示列表的函数,python,dictionary,Python,Dictionary,我想以键:值的形式显示输出,如下所示: dad:bob Mom:lisa brother : joe & so on 但输出中只显示值 我应该对此代码进行哪些更改以获得所需的输出 d = dict(Dad='Bob', Mom='Lisa', Brother= 'joe') def f2(Dad,Mom,Brother): print Dad,Mom,Brother f2(**d) 使用**kwargs处理函数关键字参数: d = dict(Dad='Bob', Mom='L

我想以
键:值的形式显示输出,如下所示:

dad:bob
Mom:lisa
brother : joe
& so on
但输出中只显示值

我应该对此代码进行哪些更改以获得所需的输出

d = dict(Dad='Bob', Mom='Lisa', Brother= 'joe')
def f2(Dad,Mom,Brother):
    print Dad,Mom,Brother
f2(**d)

使用
**kwargs
处理函数关键字参数:

d = dict(Dad='Bob', Mom='Lisa', Brother= 'joe')
def f2(**kwargs):
    for key, value in kwargs.iteritems():
        print '%s:%s' % (key, value)
f2(**d)
印刷品:

Dad:Bob
Brother:joe
Mom:Lisa
另见:


使用
**kwargs
处理函数关键字参数:

d = dict(Dad='Bob', Mom='Lisa', Brother= 'joe')
def f2(**kwargs):
    for key, value in kwargs.iteritems():
        print '%s:%s' % (key, value)
f2(**d)
印刷品:

Dad:Bob
Brother:joe
Mom:Lisa
另见:

可能重复:可能重复: