I had this following rough code snippet.
param={'a':1,'b':2}
for k,v in param.items():
func2(k=v)
func2 is defined as:
func2(**kwargs):
print kwargs.get('a',None)
print kwargs.get('b',None)
When func2() is called the variable 'k' is being passed instead of it's value.How to pass k's value to func2(**kwargs) ?
Use **
operator :
for k, v in param.items():
func2(**{k: v})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.