It feels like I'm just missing the obvious but.. how do I add a value to a dict
if I'm given a key-value-tuple?
def foo():
# magic
return key, value
d = {}
d.update((foo(),))
Isn't there something like d.add(foot())
?
I hope I'm just in need of some coffee..
this works but I don't know this is recommended.
d.update(dict([foo()]))
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.