"int" object is not iterable.
我一直在努力摆脱它。
a = [
0,[(1,2,3),(1,2,3)],
1,[(4,5,6),(4,5,6)],
2,[(7,8,9),(7,8,9)]]
li = list() #list for storing list of tuples
i = 0 #key
d = dict((i,li) for i,li in a) #Error
print(d)
答案 0 :(得分:0)
for i, li in a
等同于
for index in range(len(a)):
i, li = a[index]
现在列表a
的第一个元素是一个int:
>>> print(a[0])
0
显然,您不能遍历int ...