Python 3 Basic Tutorial 5-while Circular statement __python

Source: Internet
Author: User

This article begins with the loop statement, which, like other programming languages, has a while loop and a for loop in Python, which describes the while loop.

Grammar:

While condition expression is true:

Do some things

There are many such loops in real life, and here's an example of a less-than-good approach. For example, I need to increase the number of clicks on an article. We know that the domestic developers, in the article information, reading the number of this piece, do a column, not according to the user's IP address to judge, but according to refresh the current article page, or the current article URL was requested an HTTP, automatically read the number plus 1. If you want to test an informational project, to increase the number of readings on an article, you can write a while loop, and then call selenium inside the Refreash method, until 1000 times the number of stops, hehe. How much reading count you want to read.

Here's an example of a simple, print 10 integers, i.e. 1 to 9

# here
's a while loop # printing the natural number within 10
condition = 1 while
condition < print
    (condition)
    condition + = 1< c5/># equivalent to condition = condition + 1

Circular statements, to note that the condition of the judgment, otherwise prone to death cycle, if a dead loop, in the Python shell hold down the keyboard Ctrl + C, stop.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.