Converting Python dict to kwargs?

I want to build a query for sunburnt(solr interface) using class inheritance and therefore adding key - value pairs together. The sunburnt interface takes keyword arguments. How can I transform a dict ({'type':'Event'}) into keyword arguments (type='Event') ?


Use the double-star (aka double-splat?) operator:

func(**{'type':'Event'})

is equivalent to

func(type='Event')
链接地址: http://www.djcxy.com/p/18174.html

上一篇: 如何为函数缓存散列* args ** kwargs?

下一篇: 将Python字典转换为kwargs?