【发布时间】:2014-02-21 17:05:00
【问题描述】:
谁能告诉我为什么这个嵌套循环只执行一次内部while部分而不是8次?
corCols = 10
corRows = 8
cCount = 0
for rCount in range(corRows):
while cCount < corCols:
print "***" + str(cCount)
cCount += 1
print "###" + str(rCount)
这会通过列打印第一次迭代,然后通过行打印迭代,但似乎只执行一次 while 部分?
【问题讨论】:
-
它是运行了10次,
for循环第一次运行。 -
你的意思是问为什么没有运行 80 次?
-
cCount 不再小于 corCols。顺便说一句,那里有一些严肃的标识符名称。