Chapter IX loop

@while cycle

And while circulating the for loop mainly by two branches.

while loop major acts performed repeatedly; when conditions are introduced to True, the loop will execute until the condition is flase will be out of the loop body. In automated testing, if the page is dynamic, the result of each execution of steps to get may be different, we can make a judgment by the while loop, know a certain condition occurs before the next step.

 

 

 Conditions for direct introduction is True, not the condition is flase, the cycle will always go on, if you want to quit just press ctrl + c

We can also set the loop body dynamic conditions, when performed every cycle, changes in conditions; until a certain condition is flase time, they jump out of the loop.

Set conditions for each cycle beginning from the second access, each cycle is equal to two-digit value will be subtracted front, so it is a loop condition into a dynamic method; take complete until every number, loop condition becomes flase, the cycle will end automatically

 

 Add dynamic conditions in the loop is frequently used to make a judgment;

In this process, we may use some keywords.

such as.

break the cycle is to terminate the meaning.

continue is out of this cycle conditions continue

pass is a placeholder, no other meaning.

 

 break the cycle is to terminate the entire meaning.

 

 continue, which means that out of this condition to continue the cycle, such as 2% means that can be divided by 2 equal to 0 on entry conditions, entry conditions continue to perform, they are able to divide by two the number will not be printed.

pass is a placeholder when debugging, and did not think like a good time to write the code can be used to write it, so that will not execute the wrong syntax is incorrect.

 

for loop, the main function is the step of extracting an element from a particular set.

The simplest is to come from one set of elements in turn;

 

 

 

 for loop approach is used, break, continue and so out of the loop function.

The for loop can traverse the list, strings, tuples, dictionaries and other data; this parameter at run time automation takes very important; because data from one file out, the general form of the form of dictionaries, lists, etc. are stored.

 

 

 

 Traverse the dictionary table, if the direct promise, the key can only print dictionary tables.

You can also find dictionary table corresponding to the key value using dictionary tables.

Or it can be nested loop.

such as

 

 Identify the two different set of letters in the string,

通过enumerate,我们可以加上索引

Guess you like

Origin www.cnblogs.com/daodexuke/p/12046808.html