Several ways to suspend execution of Python scripts __python

Source: Internet
Author: User

To go from: several ways to let Python scripts suspend execution


1.time.sleep (secs)

Reference Document Original:

Suspend execution for the given number of seconds. The argument may is a floating point number to indicate a more precise sleep time. The actual suspension time may is less than that requested because any caught signal'll terminate the sleep () following Execution of that signal ' s catching routine. Also, the suspension time could longer than requested by a arbitrary amount because of the scheduling of In the system.

Effect:

Allows the program to suspend the specified number of seconds, the parameter can be a floating-point type to specify the exact time, but the actual pause time may be longer than the requested time or shorter than the paused time.

2. Raw_input ()

To suspend a program by waiting for input

3. Os.system ("pause")

The program is paused by executing the operating system's commands, which are implemented by implementing the standard C function system ().

Python2.4 has added a new subprocess module, and it is officially recommended that you replace Os.system with a replacement module, so you can write:

Subprocess.call ("Pause", shell=true)

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.