【发布时间】:2015-11-21 21:24:29
【问题描述】:
为什么会出现这种类型错误?
通常,我现在会使用enumerate(),但我特别想在这个给定范围内进行迭代:
r1 = (0,0,100,100)
r2 = (20,20,40,40)
r3 = (40,40,80,80)
these_objects = []
objects.append(r1)
objects.append(r2)
objects.append(r3)
objects_clone = copy.copy(these_objects)
iterations = int(len(objects_clone))-1
print(iterations)
for this_index, this_object in range(0, iterations):
# ...
例外:
2
Traceback (most recent call last):
File "test/test.py", line 50, in <module>
for this_index, this_object in range(0, iterations):
TypeError: 'int' object is not iterable
【问题讨论】: