how join tuple list a dict?
this is what i have:
[('a','b'),('c','d'),('e','f')]
and this is what i want:
{'a':'b','c':'d','e':'f'}
thanks!
Just pass the list into the dict
constructor. As they are tuples, it will know how to create the dictionary.
l = [('a','b'),('c','d'),('e','f')]
d = dict(l)
dict([('a','b'),('c','d'),('e','f')]
应该做
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.