How does Python run multiple python scripts at the same time

foreword

This article is the 22nd article of this column, and I will continue to share various dry goods knowledge of python later, which is worthy of attention.

At work, you may encounter such needs more or less. Use python to run multiple python scripts at the same time at the same time . Or you need to write a one-click start bat program, run the bat script, and execute multiple python scripts at the same time. Hearing this, do you have any solutions in your mind?

In general, it is not difficult to solve this kind of demand. Let me follow the author and look directly at the solution in the text.

text

Suppose, there are the following two python scripts in the same file, as follows:

scrip1.py

import time

for i in range(1, 100):
    time.sleep(1)
    print(i)

scrip2.py

import time

for i in range(100, 200):
    time.sleep(1)
    print(i)

What we need to do now is to write a python script separately, which can execute both scripts scrip1.py and scrip2.py at the same time. Of course, students who want to test can add a few other scripts separately.

Guess you like

Origin blog.csdn.net/Leexin_love_Ling/article/details/129957997