我有一个脚本(script.py
),如下所示:
array = []
for item in table:
array.append([item.name,item.pk])
for row in array:
print row
当我运行python manage.py shell < script.py
时,一切运行正常,除了:
for row in array:
print row
永远不会执行。如果我将其更改为print array
,则打印完整数组没问题。这是怎么回事?这对我没用。
编辑:
如果我把它换成一个班轮:
for row in array: print row
脚本执行得很好。我真的很想知道这是怎么回事。