开发者

How to generate a `kwargs` list?

开发者 https://www.devze.com 2023-04-05 09:27 出处:网络
From an external file I generate the following dictionary: mydict = { \'foo\' : 123, \'b开发者_Python百科ar\' : 456 }

From an external file I generate the following dictionary:

mydict = { 'foo' : 123, 'b开发者_Python百科ar' : 456 }

Given a function that takes a **kwargs argument, how can generate the keyword-args from that dictionary?


def foo(**kwargs):
    pass

foo(**{ 'foo' : 123, 'bar' : 456 })
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号