Python opens a webpage and suspends an instance. python opens a webpage instance.

Source: Internet
Author: User

Python opens a webpage and suspends an instance. python opens a webpage instance.

This article describes how to enable and pause a web page in python. Share it with you for your reference.

The specific implementation code is as follows:

Import webbrowserimport OS webbrowser. open_new_tab ("http://www.bkjia.com/") OS. system ("pause") # Run the windows pause command and wait for the user to enter I = 0 while I <100: if downloadUrlList = None: break webbrowser. open_new_tab (downloadUrlList. pop () I = I + 1 if I % 10 = 0: OS. system ("pause ")

After running the instance in this article, the command line window will pop up to parse the webpage, and then open the page http://www.bkjia.com.

I hope this article will help you with Python programming.


Python Pause several seconds to execute the next step,

Add a latency statement before the next step.
For example, the latency Statement time. sleep (3) indicates that the program will be temporarily three seconds here.
Note that the time module must be imported at the beginning of the program, that is, import time.

Here is an example:
======================================

Import time
Print ""
Time. sleep (5)
Print "B"
Time. sleep (10)

======================================
The program will first output "a", pause for 5 seconds, and then output "B"

Hope to help you!

Several Methods to suspend execution of Python scripts

Original Reference document:
Suspend execution for the given number of seconds. the argument may be a floating point number to indicate a more precise sleep time. the actual suspension time may be less than that requested because any caught signal will terminate thesleep () following execution of that signal's catching routine. also, the suspension time may be longer than requested by an arbitrary amount because of the schedulin G of other activity in the system. the parameter can be a floating point type to specify the exact time, but the actual pause time of the program may be longer than the request time or shorter than the pause time.
2. raw_input ()
Pause the program by waiting for Input
3. OS. system ("pause ")
The program is paused by executing the operating system command. This function is implemented by implementing the Standard C function system.
Python2.4 is added to the subprocess module, and it is recommended that the OS. system be replaced by the module:
Please try it! Please add it!

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.