Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use for loop statements

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

When using a for loop statement using a for loop statement, you need to specify a variable and a list of possible values, and repeat the same command sequence for each different value until the variable value runs out of the loop. The "value list" we are talking about here is the execution condition of the for statement, which includes multiple objects with the same attributes, which need to be specified by raindrops (such as: address book, IP address is to read different variable values, which is used to execute the same set of commands one by one. Format 1:for variable value in value list do (start execution) command sequence done pattern 2: for ((number of words)) do (start execution) the Operand of the command sequence donefor statement is a variable with a name specified by the user, and a list of values is preset for the variable through the in keyword, and multiple values are separated by spaces. The sequence of commands between do.done is called "loop body", in which the execution statement needs to refer to variables to complete the corresponding task.

First assign the first value in the list to the variable and execute do. The command sequence in the done loop body; then assigns the second value in the list to the variable and executes the command sequence in the loop body. And so on, until all the values in the list are used up, and then jump to done to end the loop.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report