我正试着用
dict(existing, **kwargs)
但当kwargs通过另一个函数来时,这不起作用。 有人能帮我理解为什么会这样吗
样品测试代码:
def funct(*args, **kwargs):
a = {'a': 1, 'b': 2}
print kwargs
return dict(a, **kwargs)
def thrgh(*v, **var):
print var
funct(*v, **var)
if __name__ == '__main__':
print 'hello world'
print funct(c=3)
print 'helloWorld-thrg'
print thrgh(c=3)
输出
hello world
{'c': 3}
{'a': 1, 'c': 3, 'b': 2}
helloWorld-thrg
{'c': 3}
{'c': 3}
None
你只需要这个:
这将返回:
相关问题 更多 >
编程相关推荐