如何在后台使用depentdent shell命令运行python脚本

时间:2018-08-13 19:27:47

标签: python shell

是否可以在python脚本的后台运行shell命令?假设我有run.py,在这个脚本中我需要做,

#run shell command(in python script until script is finished)
#continue with  script

但是问题在于它们是依赖的。要运行我的脚本,我需要在同一脚本中运行shell命令。

1 个答案:

答案 0 :(得分:0)

是的,您可以在Python中使用subprocess库并检查输出状态。

例如:subprocess.check_call("exit 1", shell=True)

相关问题