python中初始化字典,接受一个元组会出现这个问题: 20
>>>a=('a','b')>>>dict(a)Traceback(mostrecentcalllast):File"<stdin>",line1,in<module>V...
>>> a = ('a','b')
>>> dict(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: dictionary update sequence element #0 has length 1; 2 is required
>>> b = (('a','b'),('c','d'))
>>> dict(b)
{'a': 'b', 'c': 'd'} 展开
>>> dict(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: dictionary update sequence element #0 has length 1; 2 is required
>>> b = (('a','b'),('c','d'))
>>> dict(b)
{'a': 'b', 'c': 'd'} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询