>>> for D in range(10):
... for i in D: #for i in 0:(0不可被迭代)
... values=[]
... values.append((i,'str'+str(i)))
... print values
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
TypeError: 'int' object is not iterable
>>> D=[0,1,2,3,4,5,6,7,8,9] #可迭代对象
>>> for i in D:
... values=[]
... values.append((i,'str'+str(i))) #values.append((i,'str'+i)) -->TypeError: cannot concatenate 'str' and 'int' objects
... print values
...
[(0, 'str0')]
[(1, 'str1')]
[(2, 'str2')]
[(3, 'str3')]
[(4, 'str4')]
[(5, 'str5')]
[(6, 'str6')]
[(7, 'str7')]
[(8, 'str8')]
[(9, 'str9')]
>>>