在python中将元组转换为字典

在python中将元组转换为字典,python,dictionary,tuples,Python,Dictionary,Tuples,我有一个元组,如下所示: (1, ['a', 'b', 'c']) 如何将这样的元组转换为以下字典 {1: ['a', 'b', 'c’]}` 我的实际元组如下所示: a = (0, ['http://www.armslist.com/posts/2997703/pittsburgh-pennsylvania-handguns-for-sale--80--1911-frame', 'http://www.armslist.com/posts/4240186/racine-wisconsin-

我有一个元组,如下所示:

(1, ['a', 'b', 'c'])
如何将这样的元组转换为以下字典

{1: ['a', 'b', 'c’]}`
我的实际元组如下所示:

a = (0, ['http://www.armslist.com/posts/2997703/pittsburgh-pennsylvania-handguns-for-sale--80--1911-frame', 'http://www.armslist.com/posts/4240186/racine-wisconsin-rifles-for-sale--stainless-winchester-m70-300wsm'])
当我试图使用
dict(a)
将其转换为字典时,它给出了一个错误:

TypeError:无法将字典更新序列元素#0转换为序列


如何解析它?

您可以将一个元组的iterable传递给一个
dict

In [22]: dict([(1,['a','b','c'])])
Out[22]: {1: ['a', 'b', 'c']}
使用
dict([a])


那本词典怎么样?Dictionary是一个键:值对,看起来更像set。很抱歉输入错误。{1:['a','b','c']}
dict([my_tuple])
将为您提供所需的词典
In[56]: a=(0, ['http://www.armslist.com/posts/2997703/pittsburgh-pennsylvania-handguns-for-sale--80--1911-frame', 'http://www.armslist.com/posts/4240186/racine-wisconsin-rifles-for-sale--stainless-winchester-m70-300wsm'])
In[57]: dict([a])
Out[57]: 
{0: ['http://www.armslist.com/posts/2997703/pittsburgh-pennsylvania-handguns-for-sale--80--1911-frame',
  'http://www.armslist.com/posts/4240186/racine-wisconsin-rifles-for-sale--stainless-winchester-m70-300wsm']}