For a while loop, however, this means the code in the else clause is executed once, after the loop is terminated (see the pseudocode shown in Listing 7).
但是对于while循环,这意味着在循环终止后,else子句中的代码被执行一次(参见清单7中的伪代码)。
The while loop (like the for loop introduced later in this article) supports three additional statements
while循环(与本文后面介绍的for 循环一样)支持三种附加语句
Seeking needs to be turned off, if even for a little while, so that the system does not run in an endless loop.
搜寻需要被关掉,即使是一小会,从而使我们的系统不会无休止的循环下去。
That's why the main test method in Listing 1 USES a while loop instead of a new for loop.
这就是为什么清单1中的main测试方法使用while循环而不是一个新的for循环。
A while loop will rarely include the number of iterations — unless it is a for loop in disguise.
while循环很少包含迭代次数——除非它是一个伪装的for循环。
For instance, you can see that any time the if condition is true, the nested while loop will execute at least one time (because the list length will be greater than zero).
例如,您可以看到,每当if条件为真的时候,嵌入其中的while循环至少会执行一次(因为list的长度肯定大于0)。
At the end of the day, you can implement the exact same program using a while loop that you can using a for loop, it's just your code is going to look slightly different.
最终,你可以执行这个程序,再使用for循环的地方使用while循环,这只是使你的代码看起来稍微有点不同。
Because the for loop hands me placeholders in between those semicolons for variables and such, now I don't have those with while loops.
因为for循环给我提供了为变量准备的占位符,它们在分号之间,现在在while循环中,我没有这些。
For each line of data returned by the data source, the while loop will take in the line as an object, and spit out a Zip tag with all the data in the database (see Listing 1).
对于由该数据源返回的每行数据,while循环将会在该行做为一个对象被调用,并且输出一个所有数据都在数据库中的Zip标记(请参阅清单1)。
Notice how this method accounts for possible weak references in the queue with the do-while loop.
请注意该方法如何用do -while循环来处理队列中可能存在的弱引用。
Instead, the program enters a while loop waiting for new connections.
相反,程序进入一个while循环,等待新的连接。
A while loop then iterates through the dataset, storing the information in a convenient array for later display.
然后,一个while循环迭代数据集,在一个方便的数组中存储信息以便将来进行显示。
V6.2 offers a new feature to automatically perform these steps for you. To move a set of tasks into a while loop, do the following.
提供了一个新功能,可以自动为您执行这些步骤。
Our diagram for the while loop contains both a condition and an asterisk, signaling iteration, but as you can see the number of iterations is unavailable.
我们的while循环图既包含条件,又包含表明迭代的星号,但您会发现,没有迭代的次数。
For this purpose, I have used a do-while loop that continues dividing the value integer by 256 until the value drops below 1.
为此,我使用了一个do -while循环,它不断地将value整数除以256,直到得到的值小于1。
Listing 7. Pseudocode for the while loop.
清单7. while循环的伪代码。
This article has introduced three Python program statements: the if statement, the while loop, and the for loop.
本文介绍了三种Python程序语句:if语句、while循环和for循环。
The upper half of this figure shows the three modeling elements to represent a while loop, a do-while loop, and a for loop.
此图的上半部分显示了三种建模元素,分别表示while loop、do-while loop和 for loop。
BuildCanary then goes back to the top of its while loop and waits for the next message.
然后,BuildCanary回到while循环的顶端,等待下一条消息。
When things go wrong the pessimist tends to blame himself, while the optimist looks for loop holes.
当犯错误时悲观主义者倾向于责备他自己,而乐观主义者寻找漏洞。
An alternative method is substitute for rapid inversion and expanding the minimized inverted form of the ALR algorithm while the outer loop of ALL is remained.
该算法的主要特点是用一种新方法代替ALR算法中的取补运算和不交化过程,同时又采纳了ALL算法中的外循环排序法。
When things go wrong, the pessimist tends to blame himself, while the optimist looks for loop holes.
当事情出错的时候,消极主义者往往会责怪自己,而乐观主义者会寻找漏洞。
GTO dc chopper is adopted for the main power supply while the switch mode control with derivative feedback loop is adopted for the main controller.
主电源采用GTO直流斩波器。主控采用带微分反馈环节的开关斩控模式。
A visual servo scheme is employed for the closed loop mode, while astronomy theory is used for the open loop mode.
其闭环工作模式采用了视觉伺服控制方法,开环工作模式则采用了天文跟踪方法;
A visual servo scheme is employed for the closed loop mode, while astronomy theory is used for the open loop mode.
其闭环工作模式采用了视觉伺服控制方法,开环工作模式则采用了天文跟踪方法;
应用推荐