【发布时间】:2012-12-07 09:32:50
【问题描述】:
while 在 for 循环中 i>10 时不会中断:
i = 0
x = 100
while i<=10:
for a in xrange(1, x+1):
print "ok"
i+=1
它会打印"ok" 100 次。当i在for循环中达到10时,如何打破while循环?
【问题讨论】:
-
只要把它扔到一个函数中,然后从内部循环中返回。
-
为什么使用=
-
@sshannin 你能说得更具体点吗?
标签: python for-loop while-loop break