Python while loop statement

Source: Internet
Author: User

This example uses Python's while statement to brush its own blog

Note: This function is only to show the powerful features of Python, not to attack anyone, let us be a citizen Netizen


Bring in the Python package you need

Import WebBrowser as web as is to change Baoming or call connection as
Import time
Import OS
Import Random

Use the Randint method inside the random package to randomly generate a number from 2 to 4.

Count = Random.randint (2,4)

Here is a while nested
A = 0
While a <count:
A = A+1
i = 0
While I <= 19:

Use the Ope_new_tab method inside the WebBrowser package to open the appropriate URL address

Web.open_new_tab (' http://xinsir.blog.51cto.com/5038915/1537866 ')
i = i + 1

Stay 1 seconds before opening the second window
Time.sleep (1)
Else

If it has been brushed 20 times, wait 1 seconds and then close the browser
Time.sleep (1)
Os.system (' taskkill/f/im chrome.exe ')

This article is from the "Loyalty" blog, make sure to keep this source http://xinsir.blog.51cto.com/5038915/1538485

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.