同时运行多个python脚本 [英] Run multiple python scripts concurrently

查看:721
本文介绍了同时运行多个python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何运行多个python脚本?此刻,我像python script1.py那样奔跑.

How can I run multiple python scripts? At the moment I run one like so python script1.py.

我已经尝试过python script1.py script2.py,但是这不起作用:仅运行第一个脚本.另外,我尝试使用这样的单个文件;

I've tried python script1.py script2.py and that doesn't work: only the first script is run. Also, I've tried using a single file like this;

import script1
import script2

python script1.py
python script2.py

但是这也不起作用.

推荐答案

使用Bash:

python script1.py &
python script2.py &

这就是整个脚本.它将同时运行两个Python脚本.

That's the entire script. It will run the two Python scripts at the same time.

Python本身可以做同样的事情,但要花很多时间输入,对于眼前的问题来说是一个不好的选择.

Python could do the same thing itself but it would take a lot more typing and is a bad choice for the problem at hand.

我认为尽管您采用错误的方法来解决问题是有可能的,但我想听听您的意思.

I think it's possible though that you are taking the wrong approach to solving your problem, and I'd like to hear what you're getting at.

这篇关于同时运行多个python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆