<pre><code>sum, Nr = 0, 12
i = Nr
while i:
sum += i
i -= 1
print ('The sum of all natural numbers up to (and inclusive of) ' + repr(Nr) +
' is ' + repr(sum))
</code></pre>
<p>所以这是Python3中一个非常简单的while循环,它返回“所有自然数之和(包括)12是78”,正如预期的那样。你知道吗</p>
<p>我困惑的是,为什么当“I”不受任何比较运算符的约束时,“while I:”条件在这里起作用。你知道吗</p>
<p>谢谢!你知道吗</p>